Benjamin, Thanks. I will point out that the contourf in Basemap behaves differently than that contourf in pylab. That is, in pylab, for contour(X,Y,Z) X,Y can be 1D whereas Z must be 2D.
However, it appears that for contourf in Basemap: from mpl_toolkits.basemap import Basemap m=Basemap() g=m.contourf(X,Y,Z) X,Y and Z must all be 2D. -Tony -- Tony Mannucci Supervisor, Ionospheric and Atmospheric Remote Sensing Group Mail-Stop 138-308, Tel > (818) 354-1699 Jet Propulsion Laboratory, Fax > (818) 393-5115 California Institute of Technology, Email > tony.mannu...@jpl.nasa.gov<mailto:tony.mannu...@jpl.nasa.gov> 4800 Oak Grove Drive, http://genesis.jpl.nasa.gov Pasadena, CA 91109 From: Benjamin Root <ben.r...@ou.edu<mailto:ben.r...@ou.edu>> Date: Tue, 31 May 2011 08:50:22 -0700 To: Tony Mannucci <anthony.j.mannu...@jpl.nasa.gov<mailto:anthony.j.mannu...@jpl.nasa.gov>> Cc: "matplotlib-users@lists.sourceforge.net<mailto:matplotlib-users@lists.sourceforge.net>" <matplotlib-users@lists.sourceforge.net<mailto:matplotlib-users@lists.sourceforge.net>> Subject: Re: [Matplotlib-users] Input array dimensions for contour or contourf On Tue, May 31, 2011 at 10:34 AM, Mannucci, Anthony J (335G) <anthony.j.mannu...@jpl.nasa.gov<mailto:anthony.j.mannu...@jpl.nasa.gov>> wrote: The following program seems to work with contour/contourf. However the documentation for the contourf function states contour(X,Y,Z) "X, Y, and Z must be arrays with the same dimensions." I am finding that contour works if the dimension of X and Y are 1, but Z must be two-dimensional. The following program seems to bear this out. Are the arrays x and y below two-dimensional, or is the documentation misleading? Thanks for your help. import numpy as N import pylab as PLT lons = N.linspace(-5.,5.,5) # Is this a one or two dimensional array? lats = N.linspace(-3.,3.,4) z = N.zeros((len(lats), len(lons))) for i in range(len(lons)): for j in range(len(lats)): z[j,i]=i+j PLT.clf() PLT.contourf(lons,lats,z) PLT.colorbar() PLT.show() -Tony Tony, contour and contourf seems to take advantage of numpy's broadcasting feature, so it is probably more correct to say that X and Y must be at least broadcastable to the shape of Z. I think there are a number of functions where this may or may not be true, and at some point we (the developers) should agree on basic input array handling and make it consistent across all plotting functions. So, technically speaking, the docs are "right", but should be clearer in this case. I will add it to my doc-fixing commit that I will do today. Ben Root
------------------------------------------------------------------------------ Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users