enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.32k stars 286 forks source link

Ghosted Axis Text #243

Open capaulson opened 9 years ago

capaulson commented 9 years ago

I've had issues with axis 'ghosting' when saving PNG images. The code to generate plots follows:

    plot = mlab.contour3d(scalars, contours=10, opacity=.8, transparent=True, figure=predictFig)
    plot.compute_normals = False
    a = mlab.axes(xlabel='Area', ylabel='Aspect Ratio', zlabel='Sweep', ranges=ranges1, nb_labels=2)
    a.axes.corner_offset=0.0601
    a.title_text_property.font_family = 'times'
    a.label_text_property.font_family = 'times'
    engine = mlab.get_engine()
    scene = engine.current_scene
    scene.scene.isometric_view()
    f = mlab.gcf()
    f.scene.camera.zoom(.9)
    f.scene.render()
    mlab.savefig('%s_prediction.pdf' % name, figure=predictFig)

This sometimes works: d2model_prediction

And sometimes produces ghosted text: d1model_prediction

Any ideas about what's going on?

capaulson commented 9 years ago

bump. any ideas on how to fix this?

kitchoi commented 8 years ago

This is caused by the orientation of the object being close to where if you rotate the object a bit, the axis will swap side. The ghost axes occur when saving a figure, i.e. when everything is rendered again. To prevent this from happening, you may (1) set the view of the camera so that the axis is safely on one side despite small deviation; OR (2) set a.axes.fly_mode = "none" then the axes would be fixed

kitchoi commented 8 years ago

For (1), setting the camera view can be achieved like this:

mlab.view(50.5, 60.5, 210.8, [33.6, 35., 28.5])

One can run with interactive python session or in mayavi2 and play with the scene to find the optimal orientation, then call mlab.view() to get the view setting.

@capaulson Hope this help.