def anim(): from mayavi import mlab as M M.options.offscreen = True M.test_mesh() f = M.figure() print f for i in range(36): f.scene.camera.azimuth(10) M.savefig('img%02i.png'%i)
def main(): from basic_move import Box from enable.api import Container container = Container() box = Box(bounds=[30, 30], position=[20, 20], padding=5) container.add(box) # Create the mlab test mesh and get references to various parts of the # VTK pipeline m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor # Create the Enable Window window = EnableVTKWindow( rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, istyle_class=tvtk.InteractorStyle, resizable="v", bounds=[100, 100], padding_top=20, padding_bottom=20, padding_left=20, ) #rwi.render() #rwi.start() mlab.show() return window, render_window
def main(): from basic_move import Box from enable.api import Container container = Container() box = Box(bounds=[30,30], position=[20,20], padding=5) container.add(box) # Create the mlab test mesh and get references to various parts of the # VTK pipeline m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor # Create the Enable Window window = EnableVTKWindow(rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, istyle_class = tvtk.InteractorStyle, resizable = "v", bounds = [100, 100], padding_top = 20, padding_bottom = 20, padding_left = 20, ) #rwi.render() #rwi.start() mlab.show() return window, render_window
def main(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index=x) for i in range(5): pd.set_data("y" + str(i), jn(i, x)) # Create some line plots of some of the data plot = Plot( pd, bgcolor="none", padding=30, border_visible=True, overlay_border=True, use_backbuffer=False) plot.legend.visible = True plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto") plot.plot(("index", "y3"), name="j_3", color="auto") plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Create the mlab test mesh and get references to various parts of the # VTK pipeline f = mlab.figure(size=(600, 500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor plot.resizable = "" plot.bounds = [200, 200] plot.padding = 25 plot.bgcolor = "lightgray" plot.outer_position = [30, 30] plot.tools.append(MoveTool(component=plot, drag_button="right")) container = OverlayPlotContainer(bgcolor="transparent", fit_window=True) container.add(plot) # Create the Enable Window window = EnableVTKWindow( rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, #istyle_class = tvtk.InteractorStyle, istyle_class=tvtk.InteractorStyleTrackballCamera, bgcolor="transparent", event_passthrough=True, ) mlab.show() return window, render_window
def start_vtk(component): f = mlab.figure(size=(700,500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor window = EnableVTKWindow(rwi, renderer, component = component, istyle_class = tvtk.InteractorStyleTrackballCamera, bgcolor = "transparent", event_passthrough = True, ) mlab.show()
def main(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index = x) for i in range(5): pd.set_data("y" + str(i), jn(i,x)) # Create some line plots of some of the data plot = Plot(pd, bgcolor="none", padding=30, border_visible=True, overlay_border=True, use_backbuffer=False) plot.legend.visible = True plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto") plot.plot(("index", "y3"), name="j_3", color="auto") plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Create the mlab test mesh and get references to various parts of the # VTK pipeline f = mlab.figure(size=(600,500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor plot.resizable = "" plot.bounds = [200,200] plot.padding = 25 plot.bgcolor = "lightgray" plot.outer_position = [30,30] plot.tools.append(MoveTool(component=plot,drag_button="right")) container = OverlayPlotContainer(bgcolor = "transparent", fit_window = True) container.add(plot) # Create the Enable Window window = EnableVTKWindow(rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, #istyle_class = tvtk.InteractorStyle, istyle_class = tvtk.InteractorStyleTrackballCamera, bgcolor = "transparent", event_passthrough = True, ) mlab.show() return window, render_window
def start_vtk(component): f = mlab.figure(size=(700, 500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor window = EnableVTKWindow( rwi, renderer, component=component, istyle_class=tvtk.InteractorStyleTrackballCamera, bgcolor="transparent", event_passthrough=True, ) mlab.show()
def main(): from tvtk.api import tvtk from mayavi import mlab from enable.vtk_backend.vtk_window import EnableVTKWindow f = mlab.figure(size=(900, 850)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor # Create the plot timer_controller = TimerController() plots = create_plot_component(timer_controller) specplot, timeplot, spectrogram = plots for i, p in enumerate(plots): p.resizable = "" p.bgcolor = "transparent" p.bounds = [200, 200] p.outer_x = 0 p.outer_y = i * 250 p.tools.append(MoveTool(p, drag_button="right")) p.tools.append(PanTool(p)) p.tools.append(ZoomTool(p)) spectrogram.tools[-1].tool_mode = "range" spectrogram.tools[-1].axis = "value" spectrogram.tools[-2].constrain = True spectrogram.tools[-2].constrain_direction = "y" container = OverlayPlotContainer(bgcolor="transparent", fit_window=True) container.add(*plots) container.timer_callback = timer_controller.on_timer window = EnableVTKWindow( rwi, renderer, component=container, istyle_class=tvtk.InteractorStyleTrackballCamera, bgcolor="transparent", event_passthrough=True, ) mlab.show()
def main(): from tvtk.api import tvtk from mayavi import mlab from enable.vtk_backend.vtk_window import EnableVTKWindow f = mlab.figure(size=(900,850)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor # Create the plot timer_controller = TimerController() plots = create_plot_component(timer_controller) specplot, timeplot, spectrogram = plots for i, p in enumerate(plots): p.set(resizable = "", bounds = [200,200], outer_x = 0, bgcolor = "transparent", ) p.outer_y = i*250 p.tools.append(MoveTool(p, drag_button="right")) p.tools.append(PanTool(p)) p.tools.append(ZoomTool(p)) spectrogram.tools[-1].set(tool_mode="range", axis="value") spectrogram.tools[-2].set(constrain=True, constrain_direction="y") container = OverlayPlotContainer(bgcolor = "transparent", fit_window = True) container.add(*plots) container.timer_callback = timer_controller.on_timer window = EnableVTKWindow(rwi, renderer, component = container, istyle_class = tvtk.InteractorStyleTrackballCamera, bgcolor = "transparent", event_passthrough = True, ) mlab.show()
A simple example of the plot of a 3D graph with Mayavi in order to test the autonomy of the gallery. """ # Code source: Alex Gramfort # License: BSD 3 clause # This will show the mlab.test_mesh figure in the gallery # sphinx_gallery_thumbnail_number = 4 from mayavi import mlab mlab.test_plot3d() mlab.figure() mlab.test_contour3d() ##################################################################### # Note: this shows that inside a cell matplotlib figures are always # put before mayavi in the example HTML. In other words, the order of # plotting is not respected between matplotlib and mayavi figures mlab.figure() mlab.test_mesh() mlab.figure() mlab.test_flow() import matplotlib.pyplot as plt plt.plot([1, 2, 3], [1, 2, 3])