learning Matplotlib, several little questions...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

learning Matplotlib, several little questions...

vincent_mathoscope
This post was updated on .
i everyone i have this code :
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

# choix du style pour l'affichage des équations
plt.style.use('bmh')

# dimensions de la fenetre
(L,l)=(12,8)
Linch,linch=(L/2.54,l/2.54)
fig, lafigure = plt.subplots(figsize=(Linch,linch))

# choix de la police par défaut
mpl.rcParams['font.family'] = 'STIXGeneral'
plt.rcParams["font.size"] = 10

# liste X des abscisses pour le tracé
X = np.linspace(-np.pi, np.pi, 256,endpoint=True)

# fonctions à tracer f(X)
C,S = np.cos(X), np.sin(X)

# tracé des courbes
lafigure.plot(X, C, color="blue", linewidth=1.0, linestyle="-")
lafigure.plot(X, S, color="green", linewidth=1.0, linestyle="-")

# légendes
eq=(r"$\dfrac{1}{2+\frac{2}{xy}}fontof\mathit{equation}$font of text")
plt.text(0, 0.2, eq, ha='left', va='center', alpha=1)

# graduations sur les axes
plt.xticks([-np.pi, -np.pi/2, 0, np.pi/2, np.pi], [r'$-\pi$', r'$-\pi/2$', r'$0$', r'$+\pi/2$', r'$+\pi$'])
plt.yticks([-1, 0, +1], [r'$-1$', r'$0$', r'$+1$'])
plt.axis('on')
lafigure.spines['right'].set_visible(True)

# segments
lafigure.plot([-3,-2,-1,0,1,2,3],[0.1,-0.1,0.1,-0.1,0.1,-0.1,0.1], color ='blue', linewidth=1, linestyle="-")

# petits ronds
t=2*np.pi/3
lafigure.scatter([t],[np.cos(t)], 50, color ='blue')
lafigure.scatter([t],[np.sin(t)], 50, color ='red')

lafigure.grid('true')
#lafigure.axis(True)

plt.savefig("bordas/Matplotlib_essais/9par6.png", dpi=288)
1) if i write alos this part of code, the resulting picture does not show
the graph any longer, would you have an idea why ?


2) i dont really understand why sometimes i have to write plt.something, and
sometimes, thougt, only lafigure.something works ???

3) i have read and read these pages :
https://matplotlib.org/users/pyplot_tutorial.html
<https://matplotlib.org/users/pyplot_tutorial.html
http://python-simple.com/python-matplotlib/configuration-axes.php
<http://python-simple.com/python-matplotlib/configuration-axes.php
http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html
<http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html
https://matplotlib.org/api/pyplot_api.html
<https://matplotlib.org/api/pyplot_api.html

and i cant manage to find how to display/hide the axis (x axis and y axis)
because the word "axis" seems to be assigned to parameter the window...

thansk for your help, it is less urgent for me, i can start working without
teses answers

Vincent




Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@python.org
https://mail.python.org/mailman/listinfo/matplotlib-users
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200
Reply | Threaded
Open this post in threaded view
|

Re: learning Matplotlib, several little questions...

Paul Hobson-2
Hey Vincent,

Unfortunately your code didn't get through (at least the gmail filters).

Could you post a link to gist on github (or similar).

As for the pyplot API vs the object oriented API, it's a matter convenience (pyplot) versus explicitness (fig.<method>, ax.<method>.

If you're tinkering with some data in an interactive environment, use the pyplot API if you like it,

Personally, I always use the O-O API, even in an exploratory context (e.g., Jupyter notebooks.).

On Sat, Dec 2, 2017 at 11:26 PM, vincent_mathoscope <[hidden email]> wrote:
i everyone i have this code :


1) if i write alos this part of code, the resulting picture does not show
the graph any longer, would you have an idea why ?


2) i dont really understand why sometimes i have to write plt.something, and
sometimes, thougt, only lafigure.something works ???

3) i have read and read these pages :
https://matplotlib.org/users/pyplot_tutorial.html
<https://matplotlib.org/users/pyplot_tutorial.html>
http://python-simple.com/python-matplotlib/configuration-axes.php
<http://python-simple.com/python-matplotlib/configuration-axes.php>
http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html
<http://matplotlib.org/examples/pylab_examples/spine_placement_demo.html>
https://matplotlib.org/api/pyplot_api.html
<https://matplotlib.org/api/pyplot_api.html>

and i cant manage to find how to display/hide the axis (x axis and y axis)
because the word "axis" seems to be assigned to parameter the window...

thansk for your help, it is less urgent for me, i can start working without
teses answers

Vincent



-----
        ––––––––––––––––––––––––––
                  Vincent Douce
               :=: Mathoscope :=:
             http://mathoscope.xyz
                 06°13°11°07°26
          Bagnères de Bigorre 65200
--
Sent from: http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users