2
mlab: a simple scripting interface to Mayavi2 for 3D plotting.
4
Can be used inside Mayavi2 itself, in "ipython -wthread", or in any
5
application with the WxWidget mainloop running.
8
# Author: Prabhu Ramachandran <prabhu_r@users.sf.net>
9
# Gael Varoquaux <gael dot varoquaux at normalesup dot org>
10
# Copyright (c) 2007-2010, Enthought, Inc.
14
# Try forcing the use of wx 2.8 before any other import.
16
if not 'wx' in sys.modules:
18
from traits.etsconfig.api import ETSConfig
19
if ETSConfig.toolkit in ('wx', ''):
21
wxversion.ensureMinimal('2.8')
23
""" wxversion not installed """
27
from mayavi.tools.camera import view, roll, yaw, pitch, move
28
from mayavi.tools.figure import figure, clf, gcf, savefig, \
29
draw, sync_camera, close, screenshot
30
from mayavi.tools.engine_manager import get_engine, show_pipeline, \
32
from mayavi.tools.show import show
33
from mayavi.tools.animator import animate
36
""" This function is deprecated, please use show_pipeline.
39
warnings.warn('The show_engine function is deprecated, please use'
40
'show_pipeline', stacklevel=2)
41
return show_pipeline()
43
from tools.helper_functions import contour3d, test_contour3d, \
44
quiver3d, test_quiver3d, test_quiver3d_2d_data, \
45
points3d, test_points3d, test_molecule, \
47
imshow, test_imshow, \
48
surf, test_surf, mesh, test_mesh, test_simple_surf, \
49
test_mesh_sphere, test_fancy_mesh,\
50
contour_surf, test_contour_surf, \
51
plot3d, test_plot3d, \
52
test_plot3d_anim, test_points3d_anim, test_contour3d_anim,\
53
test_simple_surf_anim, test_flow_anim, test_mesh_sphere_anim, \
54
triangular_mesh, test_triangular_mesh, barchart, \
58
from tools.decorations import colorbar, scalarbar, vectorbar, \
59
outline, axes, xlabel, ylabel, zlabel, text, title, \
60
orientation_axes, text3d
62
import tools.pipeline as pipeline
64
from tools.tools import start_recording, stop_recording
66
if __name__ == "__main__":
72
phi = numpy.arange(0.0, 2*pi + 0.5*dphi, dphi, 'd')
74
x = numpy.cos(mu)*(1+numpy.cos(n_long*mu/n_mer)*0.5)
75
y = numpy.sin(mu)*(1+numpy.cos(n_long*mu/n_mer)*0.5)
76
z = numpy.sin(n_long*mu/n_mer)*0.5
78
pl = plot3d(x, y, z, numpy.sin(mu), tube_radius=0.05, colormap='Spectral')
80
colorbar(orientation='vertical')
82
t = numpy.linspace(0, 4*numpy.pi, 100)
91
pts = points3d(x, y, z, s, colormap="YlGnBu", scale_factor=0.1,
92
extent=(-0.3,0.3, -0.3, 0.3, -0.2,0.2))
94
axes(xlabel='X', ylabel='Y', zlabel='Z')
97
title('Mayavi rocks', height=0.85)