Matplotlib中文显示的问题
-
-
-
-
-
- from pylab import *
- mpl.rcParams['font.sans-serif'] = ['SimHei']
-
- mpl.rcParams['axes.unicode_minus'] =
False
-
- t = arange(-5*pi,
5*pi, 0.01)
- y = sin(t)/t
- plt.plot(t, y)
- plt.title(u'这里写的是中文')
- plt.xlabel(u'X坐标')
- plt.ylabel(u'Y坐标')
- plt.show()
-
-
-
-
-
-
-
-
- from pylab import *
- myfont = matplotlib.font_manager.FontProperties(fname='C:/Windows/Fonts/msyh.ttf')
- mpl.rcParams['axes.unicode_minus'] =
False
- t = arange(-5*pi,
5*pi, 0.01)
- y = sin(t)/t
- plt.plot(t, y)
- plt.title(u'这里写的是中文',fontproperties=myfont)
- plt.xlabel(u'X坐标',fontproperties=myfont)
- plt.ylabel(u'Y坐标',fontproperties=myfont)
- plt.show()
原文地址:https://www.cnblogs.com/chenjianhong/p/4145001.html