matplotlib.pyplot在显示时无法找到合适的字体,故显示乱码(我的显示为方框)
添加相关包,指定相关字体
1 from matplotlib import pyplot 2 from matplotlib.font_manager import FontProperties 3 font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=15) 4 5 pyplot.title(u‘中文‘, fontproperties=font_set) 6 pyplot.xlabel(u‘中文‘, fontproperties=font_set) 7 pyplot.ylabel(u‘中文‘, fontproperties=font_set)
Successfully !!!
有趣的事,Python永远不会缺席!还不来加我,瞅什么Ne。哒哒哒。。。
Matplotlib pyplot中title() xlabel() ylabel()无法显示中文(即显示方框乱码)的解决办法
原文:https://www.cnblogs.com/xxtalhr/p/11020246.html