Python 中文乱码matplotlib乱码 (Windows)

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

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



1.修改matplotlibrc文件
进入Python安装目录下的Lib\site-packages\matplotlib\mpl-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

 

posted @ 2015-01-26 14:49  一杯半盏  阅读(170)  评论(0编辑  收藏  举报