matplotlib有大量的绘图函数,在pyplot文档中有完整的列表,Matplotlib gallery中有大量的绘图实例。
在此文章中先介绍几种最常用的绘图函数,并对其中的一些绘图函数做详细的介绍。
1. 一维数据
plot绘制 线之类函数
code:http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/plot_example.py
scatter 绘制散点图
code:
http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/scatter_example.py
bar 绘制矩形块组成的图像, 各种条形图
code:http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/bar_example.py
fill/fill_between 填充多边形
code:
http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/fill_example.py
2 . 二维数据: 2维数组或图像
imshow: 显示图像或颜色映射的数组
code:
http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/imshow_example.py
pcolor/pcolormesh: 显示颜色映射的二维数组
code:
http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/pcolor_example.py
**contour, contourf, clabel: 用于绘制等值线图, 等高线等 **
code:
http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/contour_example.py
3. 矢量场图
arrow/quiver/streamplot: 绘制带箭头的矢量场图
code:
http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/vector_example.py
4. 描述数据分布情况
hist/boxplot/violinplot: 用于描述统计分布的图例
code
http://nbviewer.jupyter.org/github/matplotlib/AnatomyOfMatplotlib/blob/master/examples/statistical_example.py