title: How to include a string chain in a LaTeXed subscript in Python matplotlib
body: <p>I want to write in the legend of a matplotlib figure a variable with a subscript using LaTeX. One possible code for this kind of problem could be:</p>
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  a, b = 1, 0
  string = &quot;({0},{1})&quot;.format(n,l)
  x = np.linspace(0, 2*np.pi, 1e3)
  
  fig = plt.figure(0)
  ax = plt.subplot(111)
  ax.plot(x, np.sin(x), 'b', label = r&quot;Function for $E_{}$&quot;.format(string))
  ax.legend()
  plt.savefig(&quot;example_fig.png&quot;)
  </code></pre>
  <p>However, this code produces a plot where only the first element of the string chain &quot;string&quot; is used:
  <a href="https://i.stack.imgur.com/L3wpE.png" rel="nofollow noreferrer">Example of the problem</a></p>
  <p>I tried to solve this problem using <code>.format{string[:]}</code> or <code>$E_{{}}$</code> but it doesn't seem to work, and I don't have more ideas.</p>