Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write simultaneous subscript and superscript for a symbol with matplotlib

I'd like to get something like that: $E^{\alpha}_{\beta}$, where there are simutaneous subscript \beta and superscript \alpha for the symbol E. I type in matplotlib (1.2.x with python 2.7.1) the following code:

ax.text(0.,0.,r'E$^{\alpha}_{\beta}$')

and I get an error message:

Subscript/superscript sequence is too long. Use braces { } to remove ambiguity.

When I added extra braces to separate the superscript and subscript like

ax.text(0.,0.,r'E${^{\alpha}}_{\beta}$')

matplotlib can handle it this time, but the result is not a SIMULTANEOUS superscript and subscript, it seems the symbol E$^{\alpha}$ with a subscript \beta, where \alpha and \beta are not vertically aligned.

like image 688
renh Avatar asked Jun 27 '12 19:06

renh


People also ask

How do you write a subscript in MatPlotLib?

MatPlotLib with PythonUse xlabel and ylabel with subscripts in the text. Use the legend() method to place a legend in the plot. Adjust the padding between and around subplots. To display the figure, use the show() method.


1 Answers

Move your E into the TeX so that the processor knows what alpha and beta are hanging off of:

text(0.25, 0.5, r'$E^{\alpha}_{\beta}$', size=200)

produces

enter image description here

like image 171
DSM Avatar answered Sep 24 '22 06:09

DSM