How to use the chaco.api.PlotAxis 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 jonathanrocher / climate_model / Code / gsod_plot_5.py View on Github external
def update_main_plot(self):
        """ Build main plot
        """
        self.ts_plot = ToolbarPlot(self.arr_plot_data)
        for i, k in enumerate([k for k in self.ts_data.keys() if k != "index"]):
            renderer = self.ts_plot.plot(("index", k), name = k, color = colors[i % len(colors)])[0]
        if self.index_is_dates:
            # Index was an array of datetime: overwrite the x axis
            self.ts_plot.x_axis = None
            x_axis = PlotAxis(self.ts_plot, orientation="bottom",
                              tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
            self.ts_plot.overlays.append(x_axis)
            self.ts_plot.x_grid.tick_generator = x_axis.tick_generator
            
        if self.data_file:
            self.ts_plot.title = ("Time series visualization from %s" 
                                  % (os.path.split(self.data_file)[1]))
        else:
            self.ts_plot.title = "Time series visualization"
        attach_tools(self.ts_plot)

        # Attach the range selection to the last renderer; any one will do
        self.ts_plot.tools.append(RangeSelection(renderer, left_button_selects = False,
            auto_handle_event = False))
        # Attach the corresponding overlay
        self._range_selection_overlay = RangeSelectionOverlay(renderer,
github jonathanrocher / climate_model / Code / timeseries.py View on Github external
# Remove old plots
        container.remove(*container.components)
        for val, row in zip(self.value_ds, self.rows):
            horizon = HorizonPlot(
                index = self.index_ds,
                value = val,
                index_mapper = LinearMapper(range=index_range, stretch_data=False),
                value_mapper = BandedMapper(range=DataRange1D(val)),
                color_mapper = cmap(range=DataRange1D(val)), #color_mapper,
                negative_bands = False,
                )   
            horizon.tools.append(PanTool(horizon, constrain=True, constrain_direction="x"))
            horizon.overlays.append(PlotLabel(component=horizon, hjustify='right', text=row, overlay_position='outside left'))
            container.add(horizon)
        bottom_axis = PlotAxis(horizon, orientation="bottom",
                    tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
        container.overlays = [bottom_axis]

        container.request_redraw()
github enthought / chaco / examples / demo / financial_plot.py View on Github external
xmapper = LinearMapper(range=DataRange1D(time_ds))
    vol_mapper = LinearMapper(range=DataRange1D(vol_ds))
    price_mapper = LinearMapper(range=DataRange1D(price_ds))

    price_plot = FilledLinePlot(index = time_ds, value = price_ds,
                                index_mapper = xmapper,
                                value_mapper = price_mapper,
                                edge_color = "blue",
                                face_color = "paleturquoise",
                                alpha = 0.5,
                                bgcolor = "white",
                                border_visible = True)
    add_default_grids(price_plot)
    price_plot.overlays.append(PlotAxis(price_plot, orientation='left'))
    price_plot.overlays.append(PlotAxis(price_plot, orientation='bottom'))
    price_plot.tools.append(PanTool(price_plot, constrain=True,
                                    constrain_direction="x"))
    price_plot.overlays.append(ZoomTool(price_plot, drag_button="right",
                                          always_on=True,
                                          tool_mode="range",
                                          axis="index"))

    vol_plot = BarPlot(index = time_ds, value = vol_ds,
                       index_mapper = xmapper,
                       value_mapper = vol_mapper,
                       line_color = "transparent",
                       fill_color = "black",
                       bar_width = 1.0,
                       bar_width_type = "screen",
                       antialias = False,
                       height = 100,
github jonathanrocher / climate_model / Code / gsod_plot_3.py View on Github external
def update_main_plot(self):
        """ Build main plot
        """
        self.ts_plot = ToolbarPlot(self.arr_plot_data)
        for i, k in enumerate([k for k in self.ts_data.keys() if k != "index"]):
            self.ts_plot.plot(("index", k), name = k, color = colors[i % len(colors)])
        if self.index_is_dates:
            # Index was an array of datetime: overwrite the x axis
            self.ts_plot.x_axis = None
            x_axis = PlotAxis(self.ts_plot, orientation="bottom",
                              tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
            self.ts_plot.overlays.append(x_axis)
            self.ts_plot.x_grid.tick_generator = x_axis.tick_generator
            
        if self.data_file:
            self.ts_plot.title = "Time series visualization from %s" % self.data_file
        else:
            self.ts_plot.title = "Time series visualization"
        attach_tools(self.ts_plot)
github NMGRL / pychron / pychron / graph / time_series_graph.py View on Github external
def _set_bottom_axis(self, plota, plot, plotid, timescale=False):
        # this is a hack to hide the default plotaxis
        # since a basexyplot's axis cannot be a ScalesPlotAxis (must be instance of PlotAxis)
        # we cant remove the default axis and set the x_axis to the scaled axis
        # also we cant remove the default axis because then we cant change the axis title
        title = self._remove_bottom(plot)
        bottom = self.plotcontainer.stack_order == 'bottom_to_top'
        if bottom:
            if plotid == 0 or timescale:
                axis = ScalesPlotAxis(plota, orientation="bottom",
                                      title=title,
                                      tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem(
                                                                                                   # *HMSScales
                                                                                                   )
                                                                           # scale = TimeScale()
                                                                           )
                                        )


                plot.underlays.append(axis)
        else:
            for pi in self.plots:
                title = self._remove_bottom(pi)

            if (plotid == 0 and len(self.plots) == 1) or plotid == len(self.plots) - 1:
                axis = ScalesPlotAxis(plota, orientation="bottom",
github enthought / chaco / examples / demo / basic / horizon_plot.py View on Github external
index_mapper = LinearMapper(range=DataRange1D(index_ds), stretch_data=False)
    
    horizon = HorizonPlot(
            bands = 4,
            index = index_ds,
            value = value_ds,
            index_mapper = index_mapper,
            value_mapper = BandedMapper(range=DataRange1D(low=0, high=high)),
            color_mapper = cmap(range=value_range),
            )
    horizon.tools.append(PanTool(horizon, constrain=True, constrain_direction="x"))
    axis = PlotAxis(mapper = horizon.value_mapper, component=horizon, orientation="left",
                   tick_label_position="outside")
    horizon.overlays.append(axis)

    bottom_axis = PlotAxis(horizon, orientation="bottom",
                      tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
    horizon.overlays.append(bottom_axis)

    
    filled = FilledLinePlot(
            index = index_ds,
            value = value_ds,
            index_mapper = index_mapper,
            value_mapper = LinearMapper(range=value_range, stretch_data=False),
            fill_color = (0.81960784,  0.89803922,  0.94117647),
            edge_color = 'transparent',
            )
    filled.tools.append(PanTool(filled, constrain=True, constrain_direction="x"))
    axis = PlotAxis(mapper = filled.value_mapper, component=filled, orientation="left",
                   tick_label_position="outside")
    filled.overlays.append(axis)
github enthought / chaco / examples / demo / financial / correlations.py View on Github external
def _create_returns_plot(self):
        plot = Plot(self.plotdata)
        plot.legend.visible = True
        #FIXME: The legend move tool doesn't seem to quite work right now
        #plot.legend.tools.append(LegendTool(plot.legend))
        plot.x_axis = None
        x_axis = PlotAxis(plot, orientation="bottom",
                        tick_generator=ScalesTickGenerator(scale=CalendarScaleSystem()))
        plot.overlays.append(x_axis)
        plot.x_grid.tick_generator = x_axis.tick_generator
        for i, name in enumerate(self.plotdata.list_data()):
            if name == "times":
                continue
            renderer = plot.plot(("times", name), type="line", name=name,
                                  color=tuple(COLOR_PALETTE[i]))[0]

        # Tricky: need to set auto_handle_event on the RangeSelection
        # so that it passes left-clicks to the PanTool
        # FIXME: The range selection is still getting the initial left down
        renderer.tools.append(RangeSelection(renderer, left_button_selects = False,
            auto_handle_event = False))
        plot.tools.append(PanTool(plot, drag_button="left", constrain=True,
            constrain_direction="x"))
github enthought / chaco / examples / demo / multiaxis.py View on Github external
add_default_grids(plot)
            add_default_axes(plot)

        # Create a pan tool and give it a reference to the plot it should
        # manipulate, but don't attach it to the plot.  Instead, attach it to
        # the broadcaster.
        pan = PanTool(plot)
        broadcaster.tools.append(pan)

        container.add(plot)
        plots["Bessel j_%d"%i] = plot

    # Add an axis on the right-hand side that corresponds to the second plot.
    # Note that it uses plot.value_mapper instead of plot0.value_mapper.
    plot1 = plots["Bessel j_1"]
    axis = PlotAxis(plot1, orientation="right")
    plot1.underlays.append(axis)

    # Add the broadcast tool to the container, instead of to an
    # individual plot
    container.tools.append(broadcaster)

    legend = Legend(component=container, padding=10, align="ur")
    legend.tools.append(LegendTool(legend, drag_button="right"))
    legend.tools.append(LegendHighlighter(legend))
    container.overlays.append(legend)

    # Set the list of plots on the legend
    legend.plots = plots

    # Add the title at the top
    container.overlays.append(PlotLabel("Bessel functions",
github enthought / chaco / examples / demo / multi_line_plot_demo.py View on Github external
def _plot_default(self):
        """Create the Plot instance."""

        plot = Plot(title="MultiLinePlot Demo")
        plot.add(self.multi_line_plot_renderer)

        x_axis = PlotAxis(component=plot,
                            mapper=self.multi_line_plot_renderer.index_mapper,
                            orientation='bottom',
                            title='t (seconds)')
        y_axis = PlotAxis(component=plot,
                            mapper=self.multi_line_plot_renderer.value_mapper,
                            orientation='left',
                            title='channel')
        plot.overlays.extend([x_axis, y_axis])
        return plot