Matplotlib中文显示问题——用例子说明问题
plt.xlabel(u'\u2103'
,fontproperties
=
'SimHei'
)
#在这里,u'\u2103'是摄氏度,前面的u代表unicode,而引号里的内容,是通过在网上查找“℃”这一个符号的unicode编码得到的。这里的“摄氏度”是中文,要显示的话需要在后面加上fontproperties属性即可,这里设置的字体为黑体。
plt.ylabel(u
'幅度'
,fontproperties
=
'SimHei'
)
#也可以直接显示中文。
plt.show()
Matplotlib中支持LaTex语法,如果要显示各种美观的数学公式和数学符号,可以稍微学习下,很有用。具体语法可参见(http://wiki.gwrite.googlecode.com/hg/misc/LaTex-EquRef.html?r=1de19067fce5484bb5c39cbd049f6a47f7d8a2e9)
ylabel('Rice('+r'$\mu\mathrm{mol}$'+' '+'$ \mathrm{m}^{-2} \mathrm{s}^{-1}$'+')')
所以 只要将LaTex里的符号或者表达写入到坐标轴上即可,例如箭头是 \rightarrow, 下标是 下划线 _
ax.set_zlabel('$p_j$'+r'$_\rightarrow$'+'$_i$')