matplotlib如何写出汉字

来源:互联网 发布:电影特效软件 编辑:程序博客网 时间:2024/06/05 07:02
from matplotlib.font_manager import FontProperties  import numpy as npimport matplotlib.pyplot as plt  font = FontProperties(fname="/usr/share/fonts/truetype/droid/DroidSansFallbackFull.ttf", size=14)  plt.figure(figsize=(5,5))x=np.arange(0,5,0.1)y=np.sin(x)plt.plot(x,y,color='r',label='sin')plt.legend(loc=1)plt.xlabel(u"横坐标", fontproperties=font)  plt.ylabel(u"纵坐标", fontproperties=font)  plt.title(u"正弦函数",fontproperties=font)  plt.text(0.5,0.5,u'正弦函数',fontproperties=font)