在jupyter里面画图,并且显示中文字体

张开发
2026/4/13 22:56:52 15 分钟阅读

分享文章

在jupyter里面画图,并且显示中文字体
!pip install wget import wget wget.download(https://github.com/GrandmaCan/ML/raw/main/Resgression/ChineseFont.ttf) #下载字库 import matplotlib.pyplot as plt import matplotlib as mlp from matplotlib.font_manager import fontManager fontManager.addfont(ChineseFont.ttf) #加入字体 mlp.rc(font,family ChineseFont) #设定字体 plt.scatter(x,y,markerx,colorred) plt.title(年资-薪水) plt.show()画图小技巧w 0 b 0 y_pred x*w b plt.plot(x,y_pred,color blue,label 预测线) plt.scatter(x,y,markerx,colorred,label 真实数据) plt.title(年资-薪水) plt.xlabel(年资) plt.ylabel(月薪千) plt.legend() plt.show()

更多文章