美文网首页
Windows下,在Python中用matplotlib画图出现

Windows下,在Python中用matplotlib画图出现

作者: 哈斯勒 | 来源:发表于2019-08-07 10:23 被阅读0次

原文

方法一:每次编写代码时进行参数设置
#coding:utf-8
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
#有中文出现的情况,需要u'内容'
方法二:(一劳永逸)

1.打开设置文件
import matplotlib
matplotlib.matplotlib_fname()  #会显示matplotlibrc文件的地址
如下图:
image.png
2.进入上面的路径,找到并修改matplotlibrc文件
将文件中的
#font.family: sans-serif
去掉注释#号,修改为
font.family: Microsoft YaHei
即可显示中文

相关文章

网友评论

      本文标题:Windows下,在Python中用matplotlib画图出现

      本文链接:https://www.haomeiwen.com/subject/qfgndctx.html