1、方法一
from matplotlib.font_manager import FontProperties
#字体管理器
font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=15)
#设置中文标签
plt.title(u"测试", fontproperties=font)
plt.xlabel('横坐标', fontproperties=font)
plt.ylabel('纵坐标', fontproperties=font)
2、方法二
import pylab as mpl #import matplotlib as mpl
#设置汉字格式
# sans-serif就是无衬线字体,是一种通用字体族。
# 常见的无衬线字体有 Trebuchet MS, Tahoma, Verdana, Arial, Helvetica,SimHei 中文的幼圆、隶书等等
mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体
mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
plt.title(u"测试")
plt.xlabel('横坐标')
plt.ylabel('纵坐标')