python画图
1、直线
import matplotlib.pyplot as plt plt.plot([1,2,2.5]) plt.ylabel('some numbers') plt.xlabel('x axis') plt.show()
2、中文乱码
# encoding: utf-8 from matplotlib.font_manager import FontProperties from pylab import * x = [2,4,6,8,10] y = [1224,838,632,626,624] font = FontProperties(fname=r"C:\Windows\Fonts\SimSun.ttc", size=14) xlabel(u"text for x轴" ,fontproperties=font) ylabel(u"text for y轴" ,fontproperties=font) title(u"x轴和Y轴对应关系" ,fontproperties=font) plot(x,y) savefig('test') show()