1.介绍
matplotlib是python最著名的绘图库,十分适合交互式绘图。
matplotlib文档完备,在Gallery页面包含上百幅缩略图,打开后有源代码,使用非常方便。
Gallery网址:https://matplotlib.org/gallery/index.html
点击对应的图形,就可以看到对应的代码:
2.Matplotlib的一些绘图命令
| 函数 | 说明 |
|---|---|
| plt.plot(x,y,fmt,...) | 绘制坐标图 |
| plt.boxplot(data,notch,position) | 绘制箱型图 |
| plt.bar(left,height,width,bottom) | 绘制柱状图 |
| plt.barh(width,bottom,left,height) | 绘制横向条形图 |
| plt.polar(theta,r) | 绘制极坐标图 |
| plt.pie(data, explode) | 绘制饼状图 |
| plt.contour(X,Y,Z,N) |
绘制等值图 |
| plt.vlines() | 绘制垂直图 |
| plt.stem(x,y,linefmt,markerfmt) | 绘制柴火图 |
| plt.plot_date() | 绘制数据日期 |
| plt.psd(x,NFFT=256,pad_to,Fs) | 绘制功率谱密度图 |
| plt.cohere(x,y,NFFT=256,Fs) | 绘制X-Y相关性图 |
| plt.scatter(x,y) | 绘制散点图,x,y长度一致 |
| plt.step(x,y,where) | 绘制步阶图 |
| plt.hist(x,bins,normed) | 绘制直方图 |