On Tue, May 31, 2011 at 10:34 AM, Mannucci, Anthony J (335G) <anthony.j.mannucci@jpl.nasa.gov> wrote:
The following program seems to work with contour/contourf. However the documentation for the contourf function states
"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)):




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