1-在linux下安装出现的问题
- 需要freetype, libpng等dev库,需要先安装
- 如果没有安装PyQt4, wxPython等库,则plt.show()就没法正确的显示结果:
- 选择熟悉的PyQt4:
sudo pip install python-PyQt4
- 将/usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/matplotlibrc 中带backend改为Qt4Agg
2-matplot完整例子
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1, 5)
plt.plot(x, x*1.5, label='Normal')
plt.plot(x, x*3.0, label='Fast')
plt.plot(x, x/3.0, label='Slow')
plt.grid(True)
plt.title('Sample Growth of a Measure')
plt.xlabel('Samples')
plt.ylabel('Values Measured')
plt.legend(loc='upper left')
plt.show()
结果:
3-修改color, linestyle, maker等选项
color表:
linestyle表:
maker表:
4-修改样式的key argument
5-使用样式的例子
import matplotlib.pyplot as plt
import numpy as np
y = np.arange(1, 3, 0.3)
plt.plot(y, color='blue', linestyle='dashdot', linewidth=4,
marker='o', markerfacecolor='red', markeredgecolor='black',
markeredgewidth=3, markersize=12);
plt.show()
6-Plot types