99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2018-10-29 閱讀量: 851
python matplotlib 中文顯示參數(shù)設(shè)置

matplotlib 中文顯示亂碼問題

解決方法

方法一:
每次編寫代碼時進行參數(shù)設(shè)置

#coding:utf-8
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei'] #用來正常顯示中文標簽
plt.rcParams['axes.unicode_minus']=False #用來正常顯示負號
#有中文出現(xiàn)的情況,需要u'內(nèi)容'


方法二:
import matplotlib
matplotlib.matplotlib_fname() #將會獲得matplotlib包所在文件夾
然后進入C:\Anaconda64\Lib\site-packages\matplotlib\mpl-data該文件夾下就能看到matplotlibrc配置文件。

1)打開該配置文件,找到下面這行:

#font.serif : Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
然后,將前面的注釋去掉!
2)找中文字體放到matplotlib字體庫中。
在Windows文件夾下:C:\Windows\Fonts\Microsoft YaHei UI復(fù)制該字體,然后粘貼到C:\Anaconda64\Lib\site-packages\matplotlib\mpl-data\fonts\ttf文件夾,并給它重命名為Vera.ttf。

注明:這一步的作用其實就是將matplotlib中一個默認的字體替換為我們復(fù)制過來的中文字體,將這個中文字體命名改為matplotlib中有的字體名。
方法三:


import sys
default_encoding = 'utf-8'
if sys.getdefaultencoding() != default_encoding:
reload(sys)
sys.setdefaultencoding(default_encoding)
0.0000
2
關(guān)注作者
收藏
評論(0)

發(fā)表評論

暫無數(shù)據(jù)
推薦帖子