失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > python matplotlib jupyter中绘图使用宋体

python matplotlib jupyter中绘图使用宋体

时间:2020-04-28 18:04:52

相关推荐

python matplotlib jupyter中绘图使用宋体

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中绘图使用宋体》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。