Question

I plot a 3d surface using a 2-dimensional array and I want to draw gradient vector field. I've calculated gradient by gx,gy = numpy.gradient(Z) and know that for plotting arrows quivers3d(x,y,z,u,v,w) should be used, but I don't understand what should I give as u,v,w. Can you help me, how to do it?

Was it helpful?

Solution

From the documentation http://docs.enthought.com/mayavi/mayavi/auto/mlab_helper_functions.html#quiver3d:

u, v, w are numpy arrays giving the components of the vectors.

If only 3 arrays, u, v, and w are passed, they must be 3D arrays, and the positions of the arrows are assumed to be the indices of the corresponding points in the (u, v, w) arrays.

If 6 arrays, (x, y, z, u, v, w) are passed, the 3 first arrays give the position of the arrows, and the 3 last the components. They can be of any shape.

So u,v,w are the gradients and x,y,z are the 3D xyz coordinates of the vectors described by those gradients. So if you are not interested in those things in your visualization (it sounds like you are not?), you could call mlab.quiver3d(0,0,0,gx,gy,0).

But you have not explained whether that is what you want. If this answer is not adequate to your use case please clarify your question and I will try to update it, if I can.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top