【发布时间】:2017-10-29 17:43:31
【问题描述】:
到目前为止,我有这个:
plt.xlabel('$\delta^1^8$O \‰ vs VSMOW')
没有 promille 标志它运行良好,但是当我添加它时会出现一个空白图表。
然后我尝试了 TheImportanceOfBeingErnest 的回答:
plt.xlabel(u'$\delta^{18}$O ‰ vs VSMOW')
但后来出现了:
"UnicodeEncodeError: 'ascii' codec can't encode character '\u2030' in position 264: ordinal not in range(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')
【问题讨论】:
-
无论你是否使用乳胶(usetex),都需要完全不同的解决方案。但我在回答中已经详细说明了它们。
标签: python matplotlib graph latex