Chris,

The point is that contouring and gridding are two entirely separate 
operations--and this is true in general, not just for matplotlib. 
Contouring algorithms--at least all the ones I have looked at--work with 
data on a regular grid.  There are many ways to map scattered data to a 
regular grid, so it makes sense to do this as a separate step, so you 
can choose a gridding method that works well for your particular type of 
data set.  See 
http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

Now, if your data are already on a quadrilateral grid, as in the example 
you give, but your arrays have been flattened, then all you need to do 
is reshape your arrays so that they are 2-D, with the row number 
corresponding to Y (vertical on the plot) and the column index 
corresponding to X (horizontal).  Filling in your example below to 
include 2 values of x, and assuming all three variables are numpy 
ndarrays, you could do something like this:

x.shape = 2,3
y.shape = 2,3
z.shape = 2,3
contour(x.transpose(), y.transpose(), z.transpose())

The transposes are needed because your original z is arranged with y 
varying fastest.

Eric

Chris wrote:
> I may be a bit thick, but I am having a heck of a time figuring out how to 
> use contour() properly. 
> Specifically, I do not see why the z dimension should be a 2d array. 
> It should only take a set of x,y,z 
> coordinates to produce a surface --  what is the extra dimension for? More 
> importantly, how do I take 
> "canonical" 3-d data, e.g.:
> 
> x  y  z
> 1  1  2.3
> 1  2  4.5
> 1  3  6.1
> 2  1  7.3
> .
> .
> .
> 
> 
> and get it into the form that matplotlib demands?
> 
> Thanks,
> cf
> 
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to