matplotlib設置顯示中文

mac:
由於Mac系統自帶有中文字庫,Arial Unicode MS即爲其中一種。不需要安裝字庫,不需要修改配置文件。

import matplotlib.pyplot as plt
plt.rcParams["font.family"] = 'Arial Unicode MS'
#可用以下語句列出matploylib支持的字體文本;
import matplotlib
a=sorted([f.name for f in matplotlib.font_manager.fontManager.ttflist])
for i in a:
    print i

windows:

#導入的黑體
plt.rcParams['font.family'] = ['SimHei']

知識參考:
mac中文字體設置方法來源:Mac下設置matplotlib顯示中文

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章