Draw a line in Python Mayavi

How to draw a line in 3D space in Python Mayavi? Is there a function from the MLAB module that allows me to specify the start and end point of the line to be drawn?

+6
source share
2 answers

Check documentation on Mayavi; 3D graphics are in the tutorials and documented here . This is part of mlab , mayavi.mlab.plot3d(*args, **kwargs) .

Syntax

 plot3d(x, y, z, ...) 
+1
source

One important function that you can use when drawing lines is to represent them as a tube. In the following example, I used the X, Y, Z axis along with a three-dimensional drawing (note that in my case the sizes are large, so you can adjust them):

 import mayavi.mlab as mlab black = (0,0,0) white = (1,1,1) mlab.figure(bgcolor=white) mlab.plot3d([0, 1000], [0, 0], [0, 0], color=black, tube_radius=10.) mlab.plot3d([0, 0], [0, 1500], [0, 0], color=black, tube_radius=10.) mlab.plot3d([0, 0], [0, 0], [0, 1500], color=black, tube_radius=10.) mlab.text3d(1050, -50, +50, 'X', color=black, scale=100.) mlab.text3d(0, 1550, +50, 'Y', color=black, scale=100.) mlab.text3d(0, -50, 1550, 'Z', color=black, scale=100.) 
+2
source

Source: https://habr.com/ru/post/915490/


All Articles