使用matplotlib库中文显示问题
from matplotlib import pyplot as plt, font_manager # 字体实例对象 my_font=font_manager.FontProperties(fname="C:\Windows\Fonts\simhei.ttf") # 气温 x=range(0,120) # 时间 y=[random.randint(20,35) for i in range(120)] _x_labels=["10点{}分".format(i) for i in range(60)] _x_labels+=["11点{}分".format(i) for i in range(60)] plt.plot(x, y) # 设置中文显示 fontproperties plt.xticks(list(x)[::3],_x_labels[::3],rotation=45,fontproperties=my_font) plt.show() 来源: https://blog.csdn.net/m0_37294838/article/details/102728674