How to use the chaco.api.ArrayPlotData 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
data_file = File()

    # Tool controls
    tool_list = List([MA, CORRELATION])
    tool_chooser = Enum(values="tool_list")
    ts_list = List()
    ts1_chooser = Enum(values="ts_list")
    ts2_chooser = Enum(values="ts_list")
    # Moving average window size (in number of observations)
    ma_window_size = Int(0) 
    # Analysis details
    ts_analysis_details = Str("No details available")
    
    # Data
    ts_data = Dict()
    arr_plot_data = Instance(ArrayPlotData, ())
    times_ds = Any()   # arraydatasource for the time axis data
    index_is_dates = Bool()

    # Plots
    ts_plot = Instance(ToolbarPlot, ())
    ts_analysis_plot = Instance(ToolbarPlot, ())

    def trait_view(self, view):
        """ Build the view. The local namespace is 
        """
        return View(
            VGroup(Item('data_file', style='simple', label="HDF file to load"), 
                   HSplit(Item('ts_plot', editor=ComponentEditor(size=(400, 600)), 
                               show_label=False),
                          VGroup(Item('tool_chooser', show_label = True, label="Choose tool"),
                                 Item('ts1_chooser', label="TS 1"),
github enthought / chaco / examples / demo / multiaxis_using_Plot.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)
    plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")

    # Tweak some of the plot properties
    plot1.title = "My First Line Plot"
    plot1.padding = 50
    plot1.padding_top = 75
    plot1.legend.visible = True

    x = linspace(-5, 15.0, 100)
    y = jn(5, x)
    foreign_plot = create_line_plot((x,y), color=tuple(COLOR_PALETTE[0]), width=2.0)
github tvaught / experimental / portfolio_metrics / chaco_mpt_display.py View on Github external
container = VPlotContainer()

        ### Assemble the scatter plot of the Efficient Frontier
        x, y = self.get_stock_data()
        if not hasattr(self, "efx") or recalc:
            efx, efy, allocations = self.get_ef_data()
        else:
            efx = self.efx
            efy = self.efy

        p = self.portfolio

        symbs = p.symbols

        pd = ArrayPlotData(x=x, y=y, efx=efx, efy=efy)

        # Create some plots of the data
        plot = Plot(pd, title="Efficient Frontier")

        # Create a scatter plot (and keep a handle on it)
        stockplt = plot.plot(("x", "y"), color="transparent",
                                         type="scatter",
                                         marker="dot",
                                         marker_line_color="transparent",
                                         marker_color="transparent",
                                         marker_size=1)[0]

        efplt = plot.plot(("efx", "efy"), color=(0.0,0.5,0.0,0.25),
                                          type="scatter",
                                          marker="circle",
                                          marker_size=6)[0]
github enthought / chaco / examples / demo / nonlinear_color_mapping.py View on Github external
def _create_plot_component(model):

    # Create a plot data object and give it the model's data array.
    pd = ArrayPlotData()
    pd.set_data("imagedata", model.data)

    # Create the "main" Plot.
    plot = Plot(pd, padding=50)

    # Use a TransformColorMapper for the color map.
    tcm = TransformColorMapper.from_color_map(jet)

    # Create the image plot renderer in the main plot.
    renderer = plot.img_plot("imagedata", 
                    xbounds=model.x_array,
                    ybounds=model.y_array,
                    colormap=tcm)[0]

    # Create the colorbar.
    lm = LinearMapper(range=renderer.value_range,
github NMGRL / pychron / pychron / media_server / image_viewer.py View on Github external
def set_image(self, buf):
        '''
            buf is a file-like object
        '''
        self.container = HPlotContainer()
        pd = ArrayPlotData(x=[0, 640],
                           y=[0, 480])
        padding = [30, 5, 5, 30]
        plot = Plot(data=pd, padding=padding,
#                    default_origin=''
                    )
        self.plot = plot.plot(('x', 'y'),)[0]
        self.plot.index.sort_order = 'ascending'
        imo = ImageUnderlay(self.plot,
                            padding=padding,
                            path=buf)
        self.plot.overlays.append(imo)

        self._add_tools(self.plot)

        self.container.add(plot)
        self.container.request_redraw()
github enthought / jigna / examples / chaco_plot.py View on Github external
def _update_plot(self):
        x = linspace(-14, 14, 1000)
        y = sin(self.scaling_factor * x) * x**3
        if self.plot is None:
            plotdata = ArrayPlotData(x=x, y=y)
            plot = Plot(plotdata)
            plot.plot(("x", "y"), type="line", color="blue")
            plot.title = "sin(%s * x) * x^3" % self.scaling_factor
            plot.tools.append(ZoomTool(component=plot))
            plot.tools.append(PanTool(component=plot))
            self.plot = plot
        else:
            self.plot.data.set_data('y', y)
            self.plot.title = "sin(%s * x) * x^3" % self.scaling_factor
github enthought / chaco / examples / demo / basic / bounded_grids.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
    plot = Plot(pd, title="Line Plot", padding=50, border_visible=True)
    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.x_grid.line_color = "black"
    plot.y_grid.line_color = "black"
    xmin, xmax = 1.0, 6.0
    ymin, ymax = 0.2, 0.80001
    plot.x_grid.data_min = xmin
    plot.x_grid.data_max = xmax
    plot.x_grid.transverse_bounds = (ymin, ymax)
github enthought / chaco / examples / demo / advanced / spectrum.py View on Github external
empty_amplitude = zeros(NUM_SAMPLES)
    obj.time_data.set_data('amplitude', empty_amplitude)

    obj.time_plot = Plot(obj.time_data)
    obj.time_plot.plot(("time", "amplitude"), name="Time", color="blue")
    obj.time_plot.padding = 50
    obj.time_plot.title = "Time"
    obj.time_plot.index_axis.title = 'Time (seconds)'
    obj.time_plot.value_axis.title = 'Amplitude'
    time_range = list(obj.time_plot.plots.values())[0][0].value_mapper.range
    time_range.low = -0.2
    time_range.high = 0.2

    # Spectrogram plot
    spectrogram_data = zeros(( NUM_SAMPLES//2, SPECTROGRAM_LENGTH))
    obj.spectrogram_plotdata = ArrayPlotData()
    obj.spectrogram_plotdata.set_data('imagedata', spectrogram_data)
    spectrogram_plot = Plot(obj.spectrogram_plotdata)
    max_time = float(SPECTROGRAM_LENGTH * NUM_SAMPLES) / SAMPLING_RATE
    max_freq = float(SAMPLING_RATE / 2)
    spectrogram_plot.img_plot('imagedata',
                              name='Spectrogram',
                              xbounds=(0, max_time),
                              ybounds=(0, max_freq),
                              colormap=hot,
                              )
    range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range
    range_obj.high = 5
    range_obj.low = 0.0
    spectrogram_plot.title = 'Spectrogram'
    obj.spectrogram_plot = spectrogram_plot
github enthought / chaco / examples / demo / basic / scatter_custom_marker.py View on Github external
def _create_plot_component():

    # Create some data
    numpts = 300
    x = sort(random(numpts))
    y = random(numpts)

    # create a custom marker
    marker = make_custom_marker()

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("index", x)
    pd.set_data("value", y)

    # Create the plot
    plot = Plot(pd)
    plot.plot(("index", "value"),
              type="scatter",
              marker="custom",
              custom_symbol=marker,
              index_sort="ascending",
              color="orange",
              marker_size=3,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = "Scatter plot with custom markers"
github LTS5 / connectomeviewer / cviewer / visualization / matrix / con_matrix_viewer.py View on Github external
def _create_plot_component(self):
        
        # Create a plot data object and give it this data
        self.pd = ArrayPlotData()
        self.pd.set_data("imagedata", self.data[self.data_name])
    
        # find dimensions
        xdim = self.data[self.data_name].shape[1]
        ydim = self.data[self.data_name].shape[0]
    
        # Create the plot
        self.tplot = Plot(self.pd, default_origin="top left")
        self.tplot.x_axis.orientation = "top"
        self.tplot.img_plot("imagedata", 
                      name="my_plot",
                      xbounds=(0.5,xdim + 0.5),
                      ybounds=(0.5,ydim + 0.5),
                      colormap=jet)
    
        # Tweak some of the plot properties