title: How to display LaTeX f-strings in matplotlib
body: <p>In Python 3.6, there is the new f-string to include variables in strings which is great, but how do you correctly apply these strings to get super or subscripts printed for matplotlib?</p>
  
  <p>(to actually see the result with the subscript, you need to draw the variable <code>foo</code> on a matplotlib plot)</p>
  
  <p>In other words how do I get this behaviour: </p>
  
  <pre><code>    var = 123
      foo = r'text$_{%s}$' % var
      text&lt;sub&gt;123&lt;/sub&gt;
  </code></pre>
  
  <p>Using the new f-string syntax? So far, I have tried using a raw-string literal combined with an f-string, but this only seems to apply the subscript to the first character of the variable: </p>
  
  <pre><code>    var = 123
      foo = fr'text$_{var}$'
      text&lt;sub&gt;1&lt;/sub&gt;23
  </code></pre>
  
  <p>Because the <code>{</code> has an ambiguous function as delimiting what <code>r</code> should consider subscript and what <code>f</code> delimits as a place for the variable.</p>