Osc*_*hen 5 python latex graph matplotlib
直到现在我有这个:
plt.xlabel('$\delta^1^8$O \‰ vs VSMOW')
Run Code Online (Sandbox Code Playgroud)
它在没有 promille 标志的情况下运行良好,但是当我添加它时会出现一个空白图形。
然后我尝试了 TheImportanceOfBeingErnest 的回答:
plt.xlabel(u'$\delta^{18}$O ‰ vs VSMOW')
Run Code Online (Sandbox Code Playgroud)
但后来出现了:
“UnicodeEncodeError:‘ascii’编解码器无法对位置 264 中的字符‘\u2030’进行编码:序号不在范围内(128)”
也许这有什么问题?
from matplotlib import rc
rc('font', **{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
Run Code Online (Sandbox Code Playgroud)
解决方案(感谢 TheImportanceOfBeingErnest)
plt.rcParams['text.latex.preamble']=[r"\usepackage{wasysym}"]
Run Code Online (Sandbox Code Playgroud)
和
plt.xlabel(r'$\delta^{18}$O \textperthousand vs VSMOW')
Run Code Online (Sandbox Code Playgroud)
你需要
u"string"‰存在,但\‰不存在。所以
plt.xlabel(u'$\delta^{18}$O ‰ vs VSMOW')
Run Code Online (Sandbox Code Playgroud)
产生
Latex 没有内置 permille 标志。两种方法是
在文本模式下:使用\usepackage{textcomp}包并通过\textperthousand,
plt.xlabel(r'$\delta^{18}$O \textperthousand vs VSMOW')
Run Code Online (Sandbox Code Playgroud)在数学模式下:使用包\usepackage{wasysym}并通过\permil.
plt.xlabel(r'$\delta^{18}$O $\permil$ vs VSMOW')
Run Code Online (Sandbox Code Playgroud)
使用第一个包并使用\text{\textperthousand}内部数学模式也应该有效。
有关如何将这些包放入 matplotlib,请阅读如何在 Matplotlib 中编写自己的 LaTeX 序言?
| 归档时间: |
|
| 查看次数: |
3163 次 |
| 最近记录: |