how to use matplotlib contour()?
robert.kern at gmail.com
Wed May 24 23:40:27 CEST 2006
Grant Edwards wrote:
> I downloaded examples/contour_demo.py, and it doesn't run.
> I've searched both the user guide and the Wiki for "contour"
> and got zero hits.
> appears to be a good reference if you already know how to use
> contour(), but I could glean zero clues from it on how to
> actually use contour(). For example, it doesn't explain what
> the actual formats/types of the parameters. It explains what
> the parameters do, but not what they _are_
Yes, unfortunately, much of the documentation was written by people who were
very familiar with the Matlab interfaces that these functions are emulating.
> For example one parameter is specied as "an array". No clue as
> to how many dimensions or what the axis are.
> In another place it says "the X,Y parameters specify the (x,y)
> coordinates of a surface". _How_ do they specify the surface?
> Are they just equal length lists of x and y coordinates that
> specify len(X) points. Or do they specify a len(X) x len(Y)
> grid of points?
> Why would my Z values be a 2D array?
contour() only does contouring on gridded data. If you want to handle scattered
datapoints, you will have to do some interpolation.
So X, Y, and Z are all 2-D arrays laid out corresponding to the grid that you
have sampled. I thought the contour_demo.py example was reasonably clear on
this, but if you didn't get it to run, then I can see why you wouldn't have read it.
Talking about this on matplotlib-users will probably get these problems fixed
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list