Reputation: 433
I'd like to put a text like r'$X=1_{-1}^{+1}$' with matplotlib. I used the following code in ipython --pylab!:
text(0.1, 0.1, r'$1_{-1}^{+1}$', size=100)
In the result, the subscript and superscript are not aligned, the subscript slants a little to the left compared to the superscript.
When I use normal LaTeX (or, for example, LaTeXiT), I do not have this problem, and this is what I expect for matplotlib.
Are there any ways to correct the offset?
Upvotes: 1
Views: 618
Reputation: 87356
matplotlib
has two ways to set mathtext: it's own internal engine or via an external LaTeX call. The internal engine has the advantage that it will always be there and work, but has some limitations and and is not a complete implementation of latex. The external calls give you the rendering from a full latex install, but requires you to have latex installed, which is not a given, and errors aren't handled super well.
To enable type setting via an external call to latex set
rcParams['text.usetex'] = True
or add
text.usetex: True
to your matplotlibrc
file.
Upvotes: 1