小标
2018-12-05
来源 :
阅读 1706
评论 0
摘要:本文主要向大家介绍了【云计算】python的matplotlib库个人总结,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。
本文主要向大家介绍了【云计算】python的matplotlib库个人总结,通过具体的内容向大家展现,希望对大家学习云计算有所帮助。
1、x=np.linspace(0,10,100) 生成array([0,10,20,30...,110])(包含初始值和结束值)
2、简单的例子
把绘图窗口分成两行两列四块区域,然后在每个区域分别作图,基本步骤:
subplot(2,2,1); % 2、2、1之间没有逗号也可以
在第一块绘图
subplot(2,2,2);
在第二块绘图
subplot(2,2,3);
在第三块绘图
subplot(2,2,4);
在第四块绘图
3、ctrl+shift+F10 快速运行当前脚本
4、对函数与坐标轴之间的区域进行填充,使用fill函数
填充两个函数之间的区域,使用fill_between函数
5、区别。画一个图和画两个图之间函数的差别。
plt.xlabel() ax.set_xlabel()
plt.ylabel() ax.set_ylabel()
plt.xlim() ax.set_xlim()
plt.ylim() ax.set_ylim()
plt.title() ax.set_title()
ax.set(xlim=(0,10),ylim=(),xlabel=,title=)
6、
rng=numpy.random.RandomState(23355)
arrayA=rng.uniform(0,1,(2,3))
该段代码的目的是产生一个2行3列的assarray,其中的每个元素都是[0,1]区间的均匀分布的随机数
这里看以看到,有一个23355这个数字,其实,它是伪随机数产生器的种子,也就是“the starting point for a sequence of pseudorandom number”
对于某一个伪随机数发生器,只要该种子(seed)相同,产生的随机数序列就是相同的
rng=numpy.random.RandomState(0)
rng.rand(5)
随机产生5个0,1之间的均匀分布的随机数。
7、少用subplots,用subplot,像MATLAB那样去编程。
8、
for marker in ['o','.',',','x','+','v','^','<','>','s','d']:
plt.plot(rng.rand(5),rng.rand(5),marker, label="marker={0}".format(marker),markersize=15,
markerfacecolor='white',markeredgewidth=2,
markeredgecolor=(0,0,0.4,0.1))
plt.legend(numpoints=1)
plt.xlim(0,1.8)
format(marker)里面的marker指的是变量marker!!!
9、cyan是青色的意思
‘--c’绘制青色线条。
10、
通过 iterable 对象来迭代
for i in range(1000): pass
会导致生成一个 1000 个元素的 List,而代码:
for i in xrange(1000): pass
11、
如何输出合并单元格的内容
>>> merge = []
>>> for (rlow,rhigh,clow,chigh) in sheet2.merged_cells:
... merge.append([rlow,clow])
...>>> merge
[[1, 4], [3, 4], [5, 1]]
>>> for index in merge:
... print sheet2.cell_value(index[0],index[1])
...
friend
friend2
None
12、
from matplotlib.font_manager import *
myfont =
FontProperties(fname='D:\Python\Lib\site-packages\matplotlib\mpl-data/fonts/ttf/arcdps_font.ttf')
mpl.rcParams['axes.unicode_minus']=False
plt.xlabel('年份',fontproperties=myfont)
plt.ylabel('低保数额(元)',fontproperties=myfont)
plt.legend(prop =myfont)
解决字体问题
13、
print(df.sum(axis=1)),数组内部相加,总个数为数组个数。
print(df.sum(axis=0)),数组对应位置数字相加,总个数为单个数组中数字的个数。
14、
matplotlib.rcParams['font.sans-serif'] = ['SimHei']
matplotlib.rcParams['axes.unicode_minus'] = False
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注职坐标大数据云计算大数据安全频道!
喜欢 | 0
不喜欢 | 0
您输入的评论内容中包含违禁敏感词
我知道了

请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式AI+学习就业服务平台 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号