python matplotlib jupyter中绘图使用宋体
Jupyter中使用宋体Jupyter中使用宋体
在jupyter notebook中用matplotlib绘图会有汉字字体不显示的问题,而我们日常绘图中会有中文标题、坐标轴的需求。
解决方法为在坐标轴label中的fontproperties字段中增加宋体的属性。
import matplotlib import matplotlib.pyplot as plt#导入字体库中的宋体Songti = matplotlib.font_manager.FontProperties(fname='C:\Windows\Fonts\simsun.ttc')plt.plot([1,2,3,4])plt.xlabel('X 轴', fontproperties = Songti, fontsize = 14)plt.ylabel('Y 轴', fontproperties = Songti, fontsize = 14)plt.show()
如果觉得《python matplotlib jupyter中绘图使用宋体》对你有帮助,请点赞、收藏,并留下你的观点哦!