On 05/31/2011 08:03 AM, Benjamin Root wrote:
>
>
> On Tue, May 31, 2011 at 12:58 PM, Eric Firing <efir...@hawaii.edu
> <mailto:efir...@hawaii.edu>> wrote:
>
>     On 05/31/2011 05:50 AM, Benjamin Root wrote:
>      >
>      >
>      > 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>
>      > <mailto: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
>
>     Not quite; if x and y are 1-D, meshgrid is called to make 2-D versions,
>     which must then match Z. Broadcasting is not used or supported. So, the
>     contour docstring was not updated when this functionality was added,
>     long ago.  Consider it an undocumented feature, in need of
>     documentation.
>
>     Eric
>
>
> Well, (as a bit of a cop-out) in my edit, I didn't say that they were
> broadcasted, only that they must be broadcastable to the same shape.
> Would that suffice, or should I re-word that?

It would not be correct.

x and y must both be 2-D, with the same shape as z; or they must both be 
1-D such that len(x) is the number of columns in z and len(y) is the 
number of rows.

Eric

>
> 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. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to