python matplotlib 中文显示和参数设置

一劳永逸的方法:

import matplotlib
matplotlib.matplotlib_fname() #将会获得matplotlib包所在文件夹

找到 matplotlibrc配置文件,notepad打开重新编辑。

我成功的修改方式

中文显示修改:

font.sans-serif     : SimHei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, 

这一行去#号,加SimHei 

“-1”显示修改:

axes.unicode_minus  : False

去#号,改False

笨方法:

每次在开头加上这几行代码

#coding:utf-8
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
#有中文出现的情况,需要u'内容'

 可能不适用所有人

具体可以参考文章:https://segmentfault.com/a/1190000005144275

猜你喜欢

转载自blog.csdn.net/qq_40801709/article/details/90549217