How do I get a per mille sign in my axis title using Latex in matplotlib?

Viewed 4317

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')
1 Answers
Related