美文网首页
matplotlib中文显示问题

matplotlib中文显示问题

作者: 大邓和他的python | 来源:发表于2017-04-24 19:36 被阅读120次

#另辟蹊径解决matplotlib中文显示问题

import matplotlib

import matplotlib.pyplot as plt

x = [1,2,3,4]

y = [2,4,8,16]

myfont = matplotlib.font_manager.FontProperties(fname=r'C:/Users/thunderhit/Desktop/微软雅黑.ttf')

plt.figure()

plt.plot(x,y)

plt.title('matplotlib中文标题终于可以显示了',fontproperties=myfont)

plt.show()

相关文章

网友评论

      本文标题:matplotlib中文显示问题

      本文链接:https://www.haomeiwen.com/subject/ponpzttx.html