10

I know that we can produce a single subscript in matplotlib like

$r_i$

will give me an r with "i" as the subscript.

But I want to generate a subscript with say 3 or 4 letters, like r_ijk should give me an r with "ijk" as the subscript.

When I do the above, I only get the first ("i") to be the subscript, the rest ("j" & "k") are becoming normal scripts.

Serge Stroobandt
  • 28,495
  • 9
  • 107
  • 102
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
  • 2
    Matplotlib uses [Latex](http://www.latex-project.org/) to typeset the text within `$...$`. [This](http://www.emerson.emory.edu/services/latex/latex_117.html) is a little help about subscript and superscript. If there are no `{...}` only the first letter or command is used as sub/super-script – Francesco Montesano Mar 11 '14 at 10:26
  • @FrancescoMontesano thank for the info! the {} braces did the trick – Srivatsan Mar 11 '14 at 10:47

1 Answers1

13

I just tried $r_{ijk}$ and it did the trick! I was previously trying with () braces.

Serge Stroobandt
  • 28,495
  • 9
  • 107
  • 102
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
  • @mbatchkarov but it does not state clearly that {} braces would solve this trick, but anyway thank you for the help. – Srivatsan Mar 11 '14 at 11:04
  • Is this really working for you? I am getting a KeyError! – branwen85 Jul 10 '17 at 11:25
  • 6
    Are you using `str.format()`? If you are using that with braces like in `r'$\sigma_{ijk}={0}$'.format(num)` format is taking the contents of the first enclosed braces and since it doesn't know what `ijk` is, it is giving an error (specifically, a KeyError). You need to double braces when you want literal braces. – Nister Jul 12 '17 at 07:32