原始代码:
plt.xlabel('训练轮次(Epochs)', fontsize=14, fontweight='bold', fontproperties=chinese_font) # 设置中文字体、加大、加粗
plt.ylabel('R²值', fontsize=14, fontweight='bold', fontproperties=chinese_font) # 设置中文字体、加大、加粗
plt.title('R² 随训练轮次变化', fontsize=16, fontweight='bold', fontproperties=chinese_font) # 设置中文字体、加大、加粗
修改后代码:
plt.xlabel('训练轮次(Epochs)', fontproperties=chinese_font, fontsize=14, fontweight='bold') # 设置中文字体、加大、加粗
plt.ylabel('R²值', fontproperties=chinese_font, fontsize=14, fontweight='bold') # 设置中文字体、加大、加粗
plt.title('R² 随训练轮次变化', fontproperties=chinese_font, fontsize=16, fontweight='bold') # 设置中文字体、加大、加粗
fontproperties=chinese_font 要在fontsize之前。