how to use matplotlib contour()?
Grant Edwards
grante at visi.com
Thu May 25 09:54:56 EDT 2006
On 2006-05-24, Robert Kern <robert.kern at gmail.com> wrote:
> Yes, unfortunately, much of the documentation was written by people who were
> very familiar with the Matlab interfaces that these functions are emulating.
Since I've never used matlab, I'm a bit clueless.
>> 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.
That's what I was beginning to suspect. What confused me was
that if it required gridded data, I expected the input parameters to
specify a grid (e.g. for a 5x7 grid, the X parameter would be a
vector of 5 values, and the Y parameter would be a vector of 7
values) rather than just lie on a grid.
> If you want to handle scattered datapoints, you will have to
> do some interpolation.
>
> http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
Thanks, that looks like exactly what I need. My next step was
actually going to be to use the Delaunay triangulation module
to interpolate the data onto a much finer grid.
> 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.
I did delete some code that was attempting to label the graph,
and then it ran. The examples do use gridded data, but when I
changed them to non-gridded data, it seemed to run fine.
> Talking about this on matplotlib-users will probably get these
> problems fixed faster:
>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
After I got the demos to run, it became apparent that the
contour functions don't do what I want anyway, so it's all moot
at this point.
--
Grant Edwards grante Yow! YOW!! Now I
at understand advanced
visi.com MICROBIOLOGY and th' new
TAX REFORM laws!!
More information about the Python-list
mailing list