aistudio garbled Chinese characters

Upload an msyhbd.ttf file, and then set the font parameters.

You can find a simplified Chinese ttf file under the C: \ Windows \ Fonts folder in windows and upload it to the font folder you created.

from matplotlib import pyplot
from matplotlib import font_manager
# fname中选择一个你本机查询出来的字体 若没有中文字体则需要你本人手动安装
font = font_manager.FontProperties(fname='font/msyhbd.ttf')

# 设置x、y轴刻度的时候显示中文 在xticks、yticks加上 rotation=45, fontproperties=font 例如
pyplot.xticks(range(0, 26), 'x', rotation=45, fontproperties=font)

# 设置xy轴描述信息的时候显示中文 
pyplot.xlabel("/时间", fontproperties=font)
pyplot.ylabel("/度数", fontproperties=font)
pyplot.title("天气度数统计图表", fontproperties=font)

Published 314 original articles · 22 praises · 20,000+ views

Guess you like

Origin blog.csdn.net/qq_39451578/article/details/104820726