creating mesh data from xyz data

Hi list,

I have some files with data stored in columns:

x1 y1 z1
x2 y2 z2
x3 y3 z3
x4 y4 z4
x5 y5 z5
.......

and I need to make a contour plot of this data using matplotlib. The
problem is that contour plot functions usually handle a different kind
of input:

X=[[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],...

Y=[[y1,y1,y1,y1,y1,y1],
[y2,y2,y2,y2,y2,y2],
[y3,y3,y3,y3,y3,y3],.....

Z=[[z1,z2,z3,z4,z5,z6],
[z7,z8,zz9,z10,z11,z12],....

I usually load data using 3 lists: x, y and z; I wonder if there is
any function which is able to take these 3 lists and return the right
input for matplotlib functions.

cheers

g

Hi list,

I have some files with data stored in columns:

x1 y1 z1
x2 y2 z2
x3 y3 z3
x4 y4 z4
x5 y5 z5
.......

and I need to make a contour plot of this data using matplotlib. The
problem is that contour plot functions usually handle a different kind
of input:

X=[[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],...

Y=[[y1,y1,y1,y1,y1,y1],
[y2,y2,y2,y2,y2,y2],
[y3,y3,y3,y3,y3,y3],.....

Z=[[z1,z2,z3,z4,z5,z6],
[z7,z8,zz9,z10,z11,z12],....

I usually load data using 3 lists: x, y and z; I wonder if there is
any function which is able to take these 3 lists and return the right
input for matplotlib functions.

cheers

giuseppe

Hi Giuseppe

you can load your datafile with pylab... see my little function which
i'm using

import pylab as pl

def readXY(filename):

   x,y,z = pl.load(filename, unpack=True)
   return x,y,z

(X, Y, Z) = readXY("datafile.dat")

after that you have your values in the arrays X;Y;Z

kind regards

Giuseppe Aprea wrote:

···

Hi list,

I have some files with data stored in columns:

x1 y1 z1
x2 y2 z2
x3 y3 z3
x4 y4 z4
x5 y5 z5
.......

and I need to make a contour plot of this data using matplotlib. The
problem is that contour plot functions usually handle a different kind
of input:

X=[[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],...

Y=[[y1,y1,y1,y1,y1,y1],
[y2,y2,y2,y2,y2,y2],
[y3,y3,y3,y3,y3,y3],.....

Z=[[z1,z2,z3,z4,z5,z6],
[z7,z8,zz9,z10,z11,z12],....

I usually load data using 3 lists: x, y and z; I wonder if there is
any function which is able to take these 3 lists and return the right
input for matplotlib functions.

cheers

giuseppe

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Hi Giuseppe,

As far as I understand you are looking for numpy.meshgrid, e.g.

# grid in x- direction
x = np.linspace(0, 1, 10)
# grid in y-direction
y = np.arange(5)
# generate 2D-vectors out of x and y
x, y = np.meshgrid(x, y)
print np.shape(x)
print np.shape(y)

Furthermore you have to reshape your z-data accordingly, e.g.

z = np.reshape(z, np.shape(x))

or transposed ... this depends on the storage of your data

kind regards Matthias

···

On Wednesday 09 September 2009 12:02:31 Giuseppe Aprea wrote:

Hi list,

I have some files with data stored in columns:

x1 y1 z1
x2 y2 z2
x3 y3 z3
x4 y4 z4
x5 y5 z5
.......

and I need to make a contour plot of this data using matplotlib. The
problem is that contour plot functions usually handle a different kind
of input:

X=[[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],
[x1,x2,x3,x4,x5,x6],...

Y=[[y1,y1,y1,y1,y1,y1],
[y2,y2,y2,y2,y2,y2],
[y3,y3,y3,y3,y3,y3],.....

Z=[[z1,z2,z3,z4,z5,z6],
[z7,z8,zz9,z10,z11,z12],....

I usually load data using 3 lists: x, y and z; I wonder if there is
any function which is able to take these 3 lists and return the right
input for matplotlib functions.

cheers

giuseppe