Python 中文乱码matplotlib乱码 (Windows)

Python解决matplotlib中文乱码问题(Windows)

matplotlib是Python著名的绘图库,默认并不支持中文显示,因此在不经过修改的情况下,无法正确显示中文。本文将介绍如何解决这一问题的方法。



1.修改matplotlibrc文件
进入Python安装目录下的Libsite-packagesmatplotlibmpl-data目录,打开matplotlibrc文件,删除font.family和font.sans-serif两行前的#,并在font.sans-serif后添加微软雅黑字体(Microsoft YaHei),代码如下:
font.family         : sans-serif
font.sans-serif     : Microsoft YaHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

2.代码中别忘了unicode编码

 
转载自http://www.pythoner.com/200.html
原文地址:https://www.cnblogs.com/slankka/p/9158570.html