老师,我用引入字体文件的方式并不能实现中文字体效果,麻烦帮忙看一下,谢谢!

from matplotlib import pyplot as plt
import matplotlib
def test01():
# 构造数据
info = [10, 11, 10, 9, 3, 6, 8, 5, 7, 8, 12, 11]
# 构造每条数据显示所在的x轴坐标
x = range(0,12)
x_ticks = ['{}月'.format(i) for i in range(1,13)]
# 引入字体文件
font1 = matplotlib.font_manager.FontProperties(fname='SimHei.ttf')
# 设置x轴的刻度
plt.xticks(x,x_ticks,fontproperties=font1)
# 填充数据到图表
plt.plot(x,info)
# 显示图表
plt.show()
if __name__ == '__main__':
test01()
运行效果:
