Re: how to read a file contains x y z coordinate and plot it as 3D figure
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.