[Matplotlib-users] automatic list of r'$2$'...
vincent.adrien at gmail.com
vincent.adrien at gmail.com
Wed Dec 13 14:41:56 EST 2017
Well, isn't
```
Lx = np.arange(xmin, xmax + 1)
Lrx = [r"${}$".format(val) for val in Lx] # aka 'list comprehension'
```
producing what you are looking for?
Adrien
PS: in the long term, another (more global) approach might be to
leverage Matplotlib's formatting capabilities like the ones introduced here:
http://matplotlib.org/gallery/ticks_and_spines/tick-formatters.html
or
https://matplotlib.org/tutorials/text/usetex.html
and then simply define the ticks (meaning their value) that you want.
On 12/13/2017 10:52 AM, Vincent Douce Mathoscope wrote:
> 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$']
>
> i guess that r is an operator to deal with the $..$ expressions but not
> understand how to fix my definition
>
> thanks for your help
>
> Vincent
>
> ––––––––––––––––––––––––––
> Vincent Douce
> :=: Mathoscope :=:
> http://mathoscope.xyz
> 06°13°11°07°26
> Bagnères de Bigorre 65200
>
>
>
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-users
>
More information about the Matplotlib-users
mailing list