与unicode聊天的情节

时间:2016-11-17 00:10:35

标签: python matplotlib plot unicode python-unicode

我需要在matplotlib图的标签中加入希腊字母。我该怎么做?例如,unicode Omega是:u\u03A9。我使用plt.xlabel('label')

非常感谢

2 个答案:

答案 0 :(得分:2)

如果您正在寻找希腊字母,可以使用LaTex在线数学格式化命令(即'$\Omega$')来生成Latex字符映射中的字母。

import numpy as np
import matplotlib.pyplot as plt
plt.plot(np.arange(1000), np.random.rand(1000), 'b.')
plt.xlabel('$\Omega$', size=16)

enter image description here

以下是查找LaTex符号的好资源。

答案 1 :(得分:1)

我对matplotlib不肯定,但我认为将它们声明为unicode字符串应该可以正常工作

>>> print u'\u03A9' 
Ω