<div dir="ltr">The 'r' prefix tells python to not try an interpret any escape sequences (such at \t for 'tab' and '\n' for a new line) as escape sequences.  This is part of the core python language, not Matplotlib or latex specific!<div><br></div><div> If you did not use raw string and wanted to use θ (theta) as '$\theta$` python would go 'Ah ha! they asked for the string "$" "<TAB> "h" "e" "t" "a" "$" ' which is not what you wanted.  To get around this you can either do "$\\theta$" or r"$\theta$.   </div><div><br></div><div>Using raw strings is probably the better option as future versions of python will fail on unknown escape sequences so _every_ \ in your latex would have to be \\.</div><div><br></div><div>Tom </div></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Dec 23, 2017 at 4:39 PM Christophe BAL (via GMAIL) <<a href="mailto:projetmbc@gmail.com">projetmbc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <p>Hello.</p>
    <p><br>
    </p>
    <p>One question: why do you use raw strings ? <br>
    </p>
    <p><br>
    </p>
    <p>One suggestion: with Python 3.6, you can use  <b><font color="#cc0000">fr"${x}$"</font></b>  or simply  <b><font color="#cc0000">f"${x}$"</font></b>  if you don't really need
      raw strings.<br>
    </p></div><div text="#000000" bgcolor="#FFFFFF">
    <br>
    <div class="m_-6230315506350136977moz-cite-prefix">Le 23/12/2017 à 22:01, Vincent Douce
      Mathoscope a écrit :<br>
    </div>
    <blockquote type="cite">
      <pre>thanks Fabrice
the problems seems to be :
i get for Lrx :
'$0', '$1', '$2'
instead of
r'$0', r'$1', r'$2'
the "r" disappears
as the r is not in the chain is seems not to be considered by python as an element to keep ?
Vincent

</pre>
      <blockquote type="cite">
        <pre>Le 13 déc. 2017 à 20:42, Fabrice Silva <a class="m_-6230315506350136977moz-txt-link-rfc2396E" href="mailto:silva@lma.cnrs-mrs.fr" target="_blank"><silva@lma.cnrs-mrs.fr></a> a écrit :

Le mercredi 13 décembre 2017, Vincent Douce Mathoscope a écrit :
</pre>
        <blockquote type="cite">
          <pre>hi
i try this :
'''
Lx,x,Ly,y=[],xmin,[],ymin
Lrx,Lry=[],[]
while (x<=xmax):
   Lx.append(x)
   Lrx.append("$".join(["r'",str(x),"'"]))
   x+=1
while (y<=ymax):
   Ly.append(y)
   y+=1
'''
but it creates a Lrx list like this :
["r'$-2.5$'", "r'$-1.5$'", "r'$-0.5$'", "r'$0.5$'", "r'$1.5$'",
"r'$2.5$'"]
and i want to obtain
[r'$-2.5$', r'$-1.5$', r'$-0.5$', r'$0.5$', r'$1.5$', r'$2.5$']
</pre>
        </blockquote>
        <pre>
My suggestion

import numpy as np
tmpx = [(x, r'$%s' % x) for x in np.arange(xmin, xmax, 1)]
Lx, Lrx = zip(*tmpx)

Idem for the y stuff.
If you prefer to keep the while loop, change the Lrx line to
Lrx.append(r"$%s$" %x)
or
Lrx.append(r"${}$".format(x))
Note that you can add format specification in both solutions.


_______________________________________________
Matplotlib-users mailing list
<a class="m_-6230315506350136977moz-txt-link-abbreviated" href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a>
<a class="m_-6230315506350136977moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/matplotlib-users" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a>
</pre>
      </blockquote>
      <pre>
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             <a class="m_-6230315506350136977moz-txt-link-freetext" href="http://mathoscope.xyz" target="_blank">http://mathoscope.xyz</a>
                 06°13°11°07°26
          Bagnères de Bigorre 65200





_______________________________________________
Matplotlib-users mailing list
<a class="m_-6230315506350136977moz-txt-link-abbreviated" href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a>
<a class="m_-6230315506350136977moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/matplotlib-users" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a>
</pre>
    </blockquote>
    <br>
    </div><div text="#000000" bgcolor="#FFFFFF"><pre class="m_-6230315506350136977moz-signature" cols="72">-- 
Christophe BAL
Enseignant Agrégé de Mathématiques
Programmeur Python Amateur</pre>
  </div>

_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div>