questionhang
questionhang

Reputation: 763

how to 3dplot 3 colum data via mlab.surf

data is like this:

x,y,z
1.1,2.2,3.3
5.5,1.45,6.77

Below is my code which can only plot a plane

import numpy as np
from enthought.mayavi import mlab

x,y,zs =np.loadtxt('test',delimiter=',',usecols=(0,1,2),unpack=True,skiprows=1)
z = np.zeros((len(x), len(x)))
for xi in np.arange(len(x)):
        z[xi, xi] = zs[xi]
pl = mlab.surf(x, y, z, warp_scale="auto")
mlab.axes(xlabel='x', ylabel='y', zlabel='z')
mlab.outline(pl)

This is the effect I look forward to: http://philipp.spitzer.priv.at/notes/attachment/wiki/PythonPlotting/PythonPlottingSurf.png

Upvotes: 0

Views: 231

Answers (1)

ali_m
ali_m

Reputation: 74252

It seems to work OK to me:

enter image description here

Is that not what you were expecting?

Upvotes: 1

Related Questions