How to use the chaco.tools.api.ZoomTool function in chaco

To help you get started, we’ve selected a few chaco examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enthought / chaco / examples / demo / basic / cmap_image_aspect_ratio.py View on Github external
plot = Plot(pd)
    img_plot = plot.img_plot("imagedata",
                             xbounds=(0, 10),
                             ybounds=(0, 5),
                             colormap=jet)[0]
    img_plot.index_mapper.aspect_ratio = 0.5
    img_plot.index_mapper.maintain_aspect_ratio = True
    print('here')

    # Tweak some of the plot properties
    plot.title = "My First Image Plot"
    plot.padding = 50

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False)
    img_plot.overlays.append(zoom)
    return plot
github enthought / chaco / examples / demo / two_plots.py View on Github external
write_metadata=True,
                                            is_listener=True))
    left_plot.overlays.append(ZoomTool(left_plot, tool_mode="range"))
    left_plot.tools.append(PanTool(left_plot))

    # Create the right plot
    right_plot = Plot(plotdata)
    right_plot.index_range = left_plot.index_range
    right_plot.orientation = "v"
    right_plot.x_axis.title = "j1(x)"
    right_plot.y_axis.title = "X"
    renderer2 = right_plot.plot(("x","y2"), type="line", color="red", width=2.0)[0]
    renderer2.index = renderer.index
    renderer2.overlays.append(LineInspector(renderer2, write_metadata=True, is_listener=True))
    renderer2.overlays.append(LineInspector(renderer2, axis="value", is_listener=True))
    right_plot.overlays.append(ZoomTool(right_plot, tool_mode="range"))
    right_plot.tools.append(PanTool(right_plot))

    container = HPlotContainer(background="lightgray")
    container.add(left_plot)
    container.add(right_plot)

    return container
github enthought / chaco / examples / demo / vtk_example.py View on Github external
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.outer_position = [30,30]
    plot.tools.append(MoveTool(component=plot,drag_button="right"))
github enthought / chaco / examples / demo / basic / scatter_variable_size.py View on Github external
plot.plot(("index", "value"),
              type="scatter",
              marker="circle",
              index_sort="ascending",
              color=(1.0, 0.0, 0.74, 0.4),
              marker_size=marker_size,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = "Scatter Plot"
    plot.line_width = 0.5
    plot.padding = 50

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot, constrain_key="shift"))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)

    return plot
github enthought / chaco / examples / demo / basic / cmap_scatter.py View on Github external
# Tweak some of the plot properties
    plot.title = "Colormapped Scatter Plot with Range-selectable Data Points"
    plot.padding = 50
    plot.x_grid.visible = False
    plot.y_grid.visible = False
    plot.x_axis.font = "modern 16"
    plot.y_axis.font = "modern 16"

    # Right now, some of the tools are a little invasive, and we need the
    # actual ColomappedScatterPlot object to give to them
    cmap_renderer = plot.plots["my_plot"][0]

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot, constrain_key="shift"))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
    selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35,
                                            selection_type="mask")
    cmap_renderer.overlays.append(selection)

    # Create the colorbar, handing in the appropriate range and colormap
    colorbar = create_colorbar(plot.color_mapper)
    colorbar.plot = cmap_renderer
    colorbar.padding_top = plot.padding_top
    colorbar.padding_bottom = plot.padding_bottom

    # Create a container to position the plot and the colorbar side-by-side
    container = HPlotContainer(use_backbuffer = True)
    container.add(plot)
    container.add(colorbar)
    container.bgcolor = "lightgray"
github aestrivex / cvu / cvu / monolithic_cvu.py View on Github external
def chaco_gen(self):
		# set the diagonal of the adjmat to lower threshold rather than 0
		# otherwise the color scheme is a mess for non-sparse matrices
		#z_adjmat = (self.adj_thresdiag-np.mean(self.adj_thresdiag))/np.std(self.adj_thresdiag)
		#l_adjmat = np.log(self.adj_thresdiag/(1-self.adj_thresdiag))
 		#print np.where(np.isnan(l_adjmat))
		#l_adjmat[np.where(np.isnan(l_adjmat))]=0
		#print np.where(np.isnan(l_adjmat))
		self.conn_mat = Plot(ArrayPlotData(imagedata=self.adj_thresdiag))
		#centerpoint=np.mean(self.adj_thresdiag)/2+np.max(self.adj_thresdiag)/4+\
		#	np.min(self.adj_thresdiag)/4

		cm=ColorMapper.from_palette_array(self.cmap_connmat_pl(xrange(256)))
		self.conn_mat.img_plot("imagedata",name='conmatplot',colormap=cm)

		self.conn_mat.tools.append(ZoomTool(self.conn_mat))
		self.conn_mat.tools.append(ConnmatPanClickTool(self,self.conn_mat))
		self.xa=color_axis.ColorfulAxis(self.conn_mat,self.node_colors,'x')
		self.ya=color_axis.ColorfulAxis(self.conn_mat,self.node_colors,'y')
		self.conn_mat.underlays=[self.xa,self.ya]
github bright-dev / bright / bright / gui / views / component_views / views / burnup_criticality_estimator.py View on Github external
# Give me a cursor
    cursor = CursorTool(line, drag_button="left", color='red', show_value_line=False)

    # and set it's initial position (in data-space units)
    cursor.current_position = BUt, _k_BU(BU_F_, k_F_, BUt)
        
    # This is a rendered component so it goes in the overlays list
    line.overlays.append(cursor)

    # Link it up
    cursor.on_trait_change(update_positions, 'current_position')
        
    # Some other standard tools
    line.tools.append(PanTool(line, drag_button="right"))
    line.overlays.append(ZoomTool(line))

    plot.overlays.append(PlotLabel('Burnup-Criticality Estimator',
        component=plot,
        font = "Roman 20",
        overlay_position="top")
        )
        
    return plot
github bright-dev / bright / bright / gui / views / component_views / fuel_cycle_plot.py View on Github external
# Tweak some of the plot properties
    plot.title = "Fuel Cycle Plot"
    plot.line_width = 0.5
    plot.padding = 100

    plot.x_axis.title = x_name
    plot.x_axis.title_font = "Roman 16"
    plot.x_axis.tick_label_font = "Roman 12"
        
    plot.y_axis.title = y_name
    plot.y_axis.title_font = "Roman 16"
    plot.y_axis.tick_label_font = "Roman 12"

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
   
    return plot
github enthought / chaco / examples / demo / basic / scrollbar.py View on Github external
def _create_plot_component():

    # 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
    plot1 = Plot(pd, padding=50)
    plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")
    plot1.plot(("index", "y3"), name="j_3", color="blue")

    # Attach some tools to the plot
    plot1.tools.append(PanTool(plot1))
    zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False)
    plot1.overlays.append(zoom)

    # Add the scrollbar
    hscrollbar = PlotScrollBar(component=plot1, axis="index", resizable="h",
                               height=15)
    plot1.padding_top = 0
    hscrollbar.force_data_update()

    # Create a container and add our plots
    container = VPlotContainer()
    container.add(plot1)
    container.add(hscrollbar)

    return container
github enthought / chaco / examples / demo / basic / grid_container_aspect_ratio.py View on Github external
plot.plot(("index", "y" + str(i)),
                  color=tuple(COLOR_PALETTE[i]), line_width=2.0,
                  bgcolor = "white", border_visible=True)

        # Tweak some of the plot properties
        plot.border_width = 1
        plot.padding = 10

        # Set each plot's aspect ratio based on its position in the
        # 3x3 grid of plots.
        n,m = divmod(i, 3)
        plot.aspect_ratio = float(n+1) / (m+1)

        # Attach some tools to the plot
        plot.tools.append(PanTool(plot))
        zoom = ZoomTool(plot, tool_mode="box", always_on=False)
        plot.overlays.append(zoom)

        # Add to the grid container
        container.add(plot)
    return container