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、
https://www.cnblogs.com/wj-1314/p/8490822.html
多用迭代器,少用列表,(前提是你迭代器弄得很会,yield迭代器占用内存更少)
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