N. Virgo
N. Virgo

Reputation: 8439

Changing the order of axes in Mayavi

I am generating STL files for 3D printing and then using mlab/mayavi to display them. I would like the Z axis to remain vertical as I rotate the image. According to the mayavi documentation, this can be achieved using the following incantation:

fig = mlab.gcf()
from tvtk.api import tvtk
fig.scene.interactor.interactor_style = tvtk.InteractorStyleTerrain()

Unfortunately, as you can see from this screenshot of my app, it is not the Z axis but the Y axis that gets maintained vertical.

enter image description here

This is an issue because 3D printers always think of Z as the vertical axis, so I really need Z and not Y to be oriented vertically. Is there a way in which this can be achieved?

Upvotes: 0

Views: 673

Answers (2)

RobinJohansson
RobinJohansson

Reputation: 21

I have experienced the same problem, vertically aligned along the y-axis.

To get the scene to align vertically along the z-axis (which you want), you can simply add a scene.mlab.view() call before setting the interactor.

The scene.mlab.view() call aligns the camera correctly (with z up), before the interactor is set. I have found this solution by simply testing a bunch of stuff, I could not find this "hack" in the documentation.

New code:

fig = mlab.gcf()
from tvtk.api import tvtk
fig.scene.mlab.view(0, 90)
fig.scene.interactor.interactor_style = tvtk.InteractorStyleTerrain()

Upvotes: 2

Felipe Lema
Felipe Lema

Reputation: 2718

You can rename them using the Mayavi button to access the pipeline, then selecting the appropiate axes object and changing the labels.

With code, you can add the xlabel, ylabel and zlabel keyword arguments to specify them. This is specified in the axes API

Upvotes: 0

Related Questions