参阅:http://c.biancheng.net/matplotlib

使用matplotlib绘制可视化图形

正确显示中文

1
2
plt.rcParams['font.sans-serif']=['SimHei']#正确显示汉字
plt.rcParams['axes.unicode_minus']=False #正确显示负号

axes类

legend函数

创建图例

1
ax.legend(handles, labels, loc)
  • labels 是一个字符串序列,用来指定标签的名称;
  • loc 是指定图例位置的参数,其参数值可以用字符串或整数来表示;
  • handles 参数,它也是一个序列,它包含了所有线型的实例;
  • 更多参数(frameon,ncol等等)

报错解决方案

This application failed to start because it could not find or load the Qt platform plugin “windows”
in “”.
Reinstalling the application may fix this problem.

将D:\python36\Library\plugins目录下的platform文件夹复制到D:\python36下。D:\python36是anaconda安装目录。