Question

J'ai trouvé ce code sur http://matplotlib.sourceforge.net/examples/pylab_examples /quiver_demo.html

from pylab import *
from numpy import ma

X,Y = meshgrid( arange(0,2*pi,.2),arange(0,2*pi,.2) )
U = cos(X)
V = sin(Y)

#1
figure()
Q = quiver( U, V)
qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W',
               fontproperties={'weight': 'bold'})
l,r,b,t = axis()
dx, dy = r-l, t-b
axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy])

title('Minimal arguments, no kwargs')

Maintenant, comment puis-je voir ce graphique? Mieux encore, comment puis-je enregistrer dans un fichier comme, disons, par exemple, JPEG? Le code semble fonctionner, mais je ne vois rien qui se passe.

Était-ce utile?

La solution

Memory Stick show() à la fin du script. Ou pour l'enregistrer dans un fichier jpg, mettez

savefig('output.jpg')
show()

Assurez-vous de mettre la commande savefig() avant la show().

Autres conseils

Idéalement, vous pouvez taper dans un shell interactif (comme PyLab de EPD Python). Dans le cas contraire, vous devez appeler explicitement la commande show()

Vous devez appeler show() ou savefig().

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top