matplotlib中文显示问题

2017-04-24  本文已影响120人  大邓和他的python

#另辟蹊径解决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()

上一篇 下一篇

猜你喜欢

热点阅读