到现在为止我有这个:
plt.xlabel('$\delta^1^8$O \‰ vs VSMOW')
没有promille符号它运行正常,但是当我添加它时会出现一个空白图表。
然后我尝试了TheImportanceOfBeingErnest的答案:
plt.xlabel(u'$\delta^{18}$O ‰ vs VSMOW')
然后出现了这个:
" UnicodeEncodeError:' ascii'编解码器无法编码字符' \ u2030'位置264:序数不在范围内(128)"
这可能有问题吗?
from matplotlib import rc
rc('font', **{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
解决方案(感谢TheImportanceOfBeingErnest)
plt.rcParams['text.latex.preamble']=[r"\usepackage{wasysym}"]
和
plt.xlabel(r'$\delta^{18}$O \textperthousand vs VSMOW')
答案 0 :(得分:2)
你需要
u"string"
‰
存在,但\‰
没有。所以
plt.xlabel(u'$\delta^{18}$O ‰ vs VSMOW')
产生
Latex没有内置的permille标志。有两种方法可以
在文字模式下:使用\usepackage{textcomp}
套餐并通过\textperthousand
获取,
plt.xlabel(r'$\delta^{18}$O \textperthousand vs VSMOW')
在数学模式下:使用包\usepackage{wasysym}
并通过\permil
获取。
plt.xlabel(r'$\delta^{18}$O $\permil$ vs VSMOW')
使用第一个包并在数学模式中使用\text{\textperthousand}
也应该可以。
有关如何将这些包装入matplotlib的内容,请阅读How to write your own LaTeX preamble in Matplotlib?