Until now I have this:
plt.xlabel('$\delta^1^8$O \‰ vs VSMOW')
It runs fine without the promille sign, however when I add it a blank graph appears.
Then I tried TheImportanceOfBeingErnest's answer:
plt.xlabel(u'$\delta^{18}$O ‰ vs VSMOW')
But then this showed up:
"UnicodeEncodeError: 'ascii' codec can't encode character '\u2030' in position 264: ordinal not in range(128)"
Maybe there is something wrong with this?
from matplotlib import rc
rc('font', **{'family':'serif','serif':['Palatino']})
rc('text', usetex=True)
Solution (thanks to TheImportanceOfBeingErnest)
plt.rcParams['text.latex.preamble']=[r"\usepackage{wasysym}"]
and
plt.xlabel(r'$\delta^{18}$O \textperthousand vs VSMOW')
You need to
u"string"
‰
exists, but \‰
does not.So
plt.xlabel(u'$\delta^{18}$O ‰ vs VSMOW')
produces
Latex does not have a permille sign built in. Two ways to go would be
In text mode: use the \usepackage{textcomp}
package and get it via \textperthousand
,
plt.xlabel(r'$\delta^{18}$O \textperthousand vs VSMOW')
In math mode: use the package \usepackage{wasysym}
and get it via \permil
.
plt.xlabel(r'$\delta^{18}$O $\permil$ vs VSMOW')
Using the first package and using \text{\textperthousand}
inside math mode should work as well.
For how to get those packages into matplotlib, read How to write your own LaTeX preamble in Matplotlib?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With