Hi,

On Sat, Apr 21, 2012 at 03:23:52PM -0400, zhixiu li wrote:

> I have a dataset like this (in data.txt)

> 1 0 0

> 2 0 0

> 1 2 3

> 1 2 3.2

> ...

> the 1st column is x and the second col is y. the last column is the

> attribute of this point.

> I want to make a 3 D plot for each points(Z will the attribute value).

> How do I read this data file to mayavi? Thank you very much!

The first thing that you need to do is to read the data in Python. For

this I would use the numpy module, with the loadtxt function.

Once you have done this, you have a 3D array with the 2 first columns

giving you the indices (x, y), and the last one the values (z).

You need to get this data in a 2D array where the position in the array

is encoded by x, y data, and the values by z.

One way is to create such an empty array, and then assign the z values in

it (this is standard array manipulation using numpy, if you need an

introduction, check out

http://scipy-lectures.github.com/intro/numpy/numpy.html).

Once you have this 2D array, you can use Mayavi's mlab.surf to plot it:

http://github.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#mayavi.mlab.surfHTH,

GaĆ«l

_______________________________________________

Enthought-Dev mailing list

[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev