目前搜到的是,下載一個字體到程序路徑,設置成默認字體。 https://blog.csdn.net/irene_loong/article/details/68955485
#圖表顯示中文設置 import matplotlib as mpl # 新增包 from matplotlib.ticker import MultipleLocator, FormatStrFormatter #新增函數 mpl.rcParams['font.size'] = 15 # 設置字體大小 custom_font = mpl.font_manager.FontProperties(fname='../cj_data/ttf/msyh.ttf') #導入下載的字體文件
# 混淆矩陣 - 二元分類效果評估方法 y_true1=list(y_test)[:100] cm = confusion_matrix(y_true1, y_pre) plt.matshow(cm) plt.title(u'混淆矩陣',fontproperties=custom_font) plt.colorbar() plt.ylabel(u'實際類型',fontproperties=custom_font) plt.xlabel(u'預測類型',fontproperties=custom_font) plt.show()