设置图像标题
如下图红框处文字

语法
matplotlib.pyplot.title(label,loc,**kwargs)
参数说明
- label:设置图的标题
- loc:标题显示位置,默认值
'center',表示居中
'left':左
'right':右 - **kwargs:
- fontproperties:设置字体,中文时必须设置此项
- fontsize:设置字体大小,int类型
例子
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
# 设置字体
my_font=fm.FontProperties(fname=r'C:\Windows\Fonts\msyh.ttc')
temps=[23,22,23,24,27,28,25,23]
hours=list(range(2,26,3))
plt.plot(hours,temps)
plt.title('气温变化情况',fontproperties=my_font,fontsize=18)
# 显示
plt.show()
原文出处:/show_1EF3nQWZPQim.html