Peter I. Hansen wrote:
> Hello
> 
> I have gridded data of the shape:
> 
> x_1 y_1 z_1
> x_1 y_2 z_2
> .       .       .
> x_1 y_N z_N
> 
> x_2 y_1 z_(N+1)
> x_2 y_2 z_(N+2)
> .       .       .
> x_2 y_N z_(2N)
> 
> x_M y_1 z_(MN)
> x_M y_2 z_(MN)
> .        .      .
> x_M y_N z_(MN)
> 
> I've tried to follow the contour_demo script by making


You don't need to make your own X, Y, so delete the following 3 lines.
> 
> x = arange(M numbers)
> y = arange(N numbers)
> X,Y = meshgrid(x,y)
> 
> M = load('zdata.dat')

Now you have X, Y, and Z, each as a column in your file, so you need to 
split them apart and reshape them.  Let's assume M, N are the number of 
X and Y values in your grid; to avoid name confusion, change the load to

XYZ = load('zdata.dat')

X = XYZ[:,0]
X.shape = (M,N)
Y = XYZ[:,1]
Y.shape = (M,N)
Z = XYZ[:,2]
Z.shape = (M,N)

CS = contour(X.transpose(), Y.transpose(), Z.transpose())

The reason for all the transposing is that pcolor and contour display 
images with column number increasing with X, and row number increasing 
with Y.  Since you have M X-values and N Y-values, everything has to end 
up N by M, not the reverse.

Eric

> 
> Z = reshape(M, (M,N))
> 
> figure()
> CS = contour(X,Y,Z)
> 
> But I get errors that x and y are not 1D or 2D... Can someone help me
> to do this right?
> thanks, Peter
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to