话很少说,上代码
# -*- coding: UTF-8 -*-
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
# windows下配置 font 为中文字体,本身去该路径找到本身电脑自带的字体
# font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=14)
# mac下配置 font 为中文字体,本身去该路径找到本身电脑自带的字体
font = FontProperties(fname='/System/Library/Fonts/STHeiti Medium.ttc')
# Python3能够不加 u,加上 fontproperties 参数便可
plt.xlabel(u'x 轴', fontproperties=font)
plt.ylabel(u'y 轴', fontproperties=font)
plt.title(u'标题' fontproperties=font)
# 注意:plt.legend()有点不一样,须要加上 prop 参数
plt.legend((type_1, type_2, type_3), ('类型一', '类型二', '类型三'), loc=4, prop=font)
plt.show()