1. 程式人生 > >pandas plot輸出圖表中無法顯示中文問題

pandas plot輸出圖表中無法顯示中文問題

解決方式一:修改配置檔案

(1)找到matplotlibrc檔案(搜尋一下就可以找到了)
(2)修改:font.serif和font.sans-serif,我的在205,206行
font.serif: SimHei, Bitstream Vera Serif, New Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif Bookman, Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
font.sans-serif: SimHei, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

解決方式二:在程式碼中修改

import matplotlib

指定預設字型

matplotlib.rcParams[‘font.sans-serif’] = [‘SimHei’]
matplotlib.rcParams[‘font.family’]=’sans-serif’

解決負號’-‘顯示為方塊的問題

matplotlib.rcParams[‘axes.unicode_minus’] = False