Python: 2D carte de la couleur avec imshow

Je suis en train d'essayer de représenter une fonction de deux variables sur un graphique à deux dimensions à l'aide de la couleur.
Je suis tombé sur cet exemple ici:

from numpy import exp,arange
from pylab import meshgrid,cm,imshow,contour,clabel,colorbar,axis,title,show
# the function that I'm going to plot
def z_func(x,y):
 return (1-(x**2+y**3))*exp(-(x**2+y**2)/2)

x = arange(-3.0,3.0,0.1)
y = arange(-3.0,3.0,0.1)
X,Y = meshgrid(x, y) # grid of point
Z = z_func(X, Y) # evaluation of the function on the grid

im = imshow(Z,cmap=cm.RdBu) # drawing the function
# adding the Contour lines with labels
cset = contour(Z,arange(-1,1.5,0.2),linewidths=2,cmap=cm.Set2)
clabel(cset,inline=True,fmt='%1.1f',fontsize=10)
colorbar(im) # adding the colobar on the right
# latex fashion title
title('$z=(1-x^2+y^3) e^{ -(x^2+y^2)/2}$')
show()

qui produit Python: 2D carte de la couleur avec imshow

Cependant, les échelles de l'axe et les limites ne correspondent pas au réel des données x et y(qui sont tous les deux entre -3 et 3). Comment faire pour les faire correspondre à des données réelles?

InformationsquelleAutor user1830663 | 2014-07-22