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顯示中文