matplotlib库
1、 matplotlib是python上的一个2D绘图库;
2、 matplotlib.pyplot提供一个类似matlab的绘图框架,可以绘制直方图,功率谱,条形图,错误图,散点图等。
先看一些pyplot库的基本操作:
#创建新窗口对象
fig = plt.figure(num=‘窗口名’, figsize=(m,n))
num:用来给窗口命名,可选
figsize:用来设置窗口大小,可选
更多参数参见help(plt.figur)
#绘制多子图图形·
fig1 = fig.add_subplot(231)
这里的‘233’代表将fig窗口对象划分为“2*3”个子图,fig1为第一个子图
#设置标题
plt.title(‘Scatter Plot’)
#设置X轴标签
plt.xlabel(‘X’)
#设置Y轴标签
plt.ylabel(‘Y’)
#显示所画的图
plt.show()
散点图
原型:
matplotlib.pyplot.scatter(x, y, s=None, c=None, marker=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, verts=None, edgecolors=None,*, plotnonfinite=False, data=None, **kwargs)
参数:
x,y:array_like, shape (n, )
s:scalar or array_like, shape (n, ), optional
c:color, sequence, or sequence of color, optional
The marker color. Possible values:
- A single color format string.
- A sequence of color specifications of length n.
- A sequence of n numbers to be mapped to colors using *cmap* and
*norm*.
- A 2-D array in which the rows are RGB or RGBA.
marker:MarkerStyle,optional
alpha:scalar, optional, default: None
The alpha blending value, between 0 (transparent) and 1 (opaque).
scatter参数先介绍这些,后面有用到其他的再更新……
未完待续…