Ejemplo n.º 1
0
 def _plot_data_default(self):
     data = ArrayPlotData(forest_image=self.forest_image,
                          tree_history=self.tree_history,
                          fire_history=self.fire_history,
                          fractions=self.fractions,
                          density_function=self.density_function,
                          time=self.time)
     return data
Ejemplo n.º 2
0
 def _plot_default(self):
     x = linspace(-14, 14, 100)
     y = sin(x) * x**3
     plotdata = ArrayPlotData(x=x, y=y)
     plot = Plot(plotdata)
     plot.plot(("x", "y"), type="line", color="blue")
     plot.title = "sin(x) * x^3"
     return plot
Ejemplo n.º 3
0
 def __init__(self, *args, **kw):
     super(Viewer, self).__init__(*args, **kw)
     plotdata = ArrayPlotData(time=self.index, x=self.eW_data_x)
     plot = Plot(plotdata)
     plot.plot(('time', 'x'), type="scatter", color="blue")
     self.plot_eW = plot
     self.plot_eR = plot
     self.plot_M = plot
 def _create_data(self, *names):
     numpoints = self.numpoints
     plotdata = ArrayPlotData(times=create_dates(numpoints))
     for name in names:
         plotdata.set_data(
             name, cumprod(random.lognormal(
                 0.0, 0.04, size=numpoints)))
     self.plotdata = plotdata
Ejemplo n.º 5
0
 def __init__(self):
     super(PlotError).__init__()
     x = np.linspace(-10, 10)
     y = np.sin(x)
     plotdata = ArrayPlotData(x=x, y=y)
     plot = Plot(plotdata)
     plot.plot(('x', 'y'), type='line', color='blue')
     self.plot = plot
Ejemplo n.º 6
0
    def _apd_default(self):
        # Create the data to plot.
        px = np.array([0.5, 1.0, 2.0, 2.5, 2.0, 1.5, 0.5, 0.0])
        py = np.array([0.0, 0.8, 0.5, 3.0, 3.5, 2.0, 3.0, 0.5])

        # Create the ArrayPlotData container used by the Plot.
        apd = ArrayPlotData(px=px, py=py)
        return apd
Ejemplo n.º 7
0
 def __init__(self, treasure_chest=None, data_path='/rawdata', *args, **kw):
     super(MDAViewController, self).__init__(*args, **kw)
     self.factor_plotdata = ArrayPlotData()
     self.score_plotdata = ArrayPlotData()
     if treasure_chest is not None:
         self.numfiles = len(treasure_chest.list_nodes(data_path))
         self.chest = treasure_chest
         self.data_path = data_path
         # populate the list of available contexts (if any)
         if self.chest.root.mda_description.nrows > 0:
             self._contexts = self.chest.root.mda_description.col(
                 'context').tolist()
             context = self.get_context_name()
             self.dimensionality = self.chest.get_node_attr(
                 '/mda_results/' + context, 'dimensionality')
             self.update_factor_image()
             self.update_score_image()
Ejemplo n.º 8
0
    def _create_window(self):
        # Create the model
        #try:
        #    self.model = model = BrainModel()
        #    cmap = bone
        #except SystemExit:
        #    sys.exit()
        #except:
        #    print "Unable to load BrainModel, using generated data cube."
        self.model = model = Model()
        cmap = jet
        self._update_model(cmap)

        datacube = self.colorcube

        # Create the plot
        self.plotdata = ArrayPlotData()
        self._update_images()

        # Center Plot
        centerplot = Plot(self.plotdata, padding=0)
        imgplot = centerplot.img_plot("xy",
                                xbounds=(model.xs[0], model.xs[-1]),
                                ybounds=(model.ys[0], model.ys[-1]),
                                colormap=cmap)[0]
        self._add_plot_tools(imgplot, "xy")
        self.center = imgplot

        # Right Plot
        rightplot = Plot(self.plotdata, width=150, resizable="v", padding=0)
        rightplot.value_range = centerplot.value_range
        imgplot = rightplot.img_plot("yz",
                                xbounds=(model.zs[0], model.zs[-1]),
                                ybounds=(model.ys[0], model.ys[-1]),
                                colormap=cmap)[0]
        self._add_plot_tools(imgplot, "yz")
        self.right = imgplot

        # Bottom Plot
        bottomplot = Plot(self.plotdata, height=150, resizable="h", padding=0)
        bottomplot.index_range = centerplot.index_range
        imgplot = bottomplot.img_plot("xz",
                                xbounds=(model.xs[0], model.xs[-1]),
                                ybounds=(model.zs[0], model.zs[-1]),
                                colormap=cmap)[0]
        self._add_plot_tools(imgplot, "xz")
        self.bottom = imgplot

        # Create Container and add all Plots
        container = GridPlotContainer(padding=20, fill_padding=True,
                                      bgcolor="white", use_backbuffer=True,
                                      shape=(2,2), spacing=(12,12))
        container.add(centerplot)
        container.add(rightplot)
        container.add(bottomplot)

        self.container = container
        return Window(self, -1, component=container)
Ejemplo n.º 9
0
def _create_plot_component():

    # Create some data
    numpts = 1000
    x = numpy.arange(0, numpts)
    y = numpy.random.random(numpts)
    marker_size = numpy.random.normal(4.0, 4.0, numpts)
    color = numpy.random.random(numpts)

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

    # Because this is a non-standard renderer, we can't call plot.plot, which
    # sets up the array data sources, mappers and default index/value ranges.
    # So, its gotta be done manually for now.

    index_ds = ArrayDataSource(x)
    value_ds = ArrayDataSource(y)
    color_ds = ArrayDataSource(color)

    # Create the plot
    plot = Plot(pd)
    plot.index_range.add(index_ds)
    plot.value_range.add(value_ds)

    # Create the index and value mappers using the plot data ranges
    imapper = LinearMapper(range=plot.index_range)
    vmapper = LinearMapper(range=plot.value_range)

    # Create the scatter renderer
    scatter = ColormappedScatterPlot(
        index=index_ds,
        value=value_ds,
        color_data=color_ds,
        color_mapper=viridis(range=DataRange1D(low=0.0, high=1.0)),
        fill_alpha=0.4,
        index_mapper=imapper,
        value_mapper=vmapper,
        marker='circle',
        marker_size=marker_size)

    # Append the renderer to the list of the plot's plots
    plot.add(scatter)
    plot.plots['var_size_scatter'] = [scatter]

    # Tweak some of the plot properties
    plot.title = "Variable Size and Color 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
Ejemplo n.º 10
0
    def __init__(self,
                 velocity_callback=None,
                 x_range=DataRange1D(low=0, high=size[0]),
                 y_range=DataRange1D(low=0, high=size[1]),
                 *args,
                 **kwargs):
        super().__init__(*args, **kwargs)

        self.robot_bounding_box = {
            "x": [100, 200, 200, 100],
            "y": [80, 80, 220, 220]
        }

        self.robot_wheels = [
            {  # Bottom-left
                "x": [90, 110, 110, 90],
                "y": [90, 90, 140, 140]
            },
            {  # Bottom-right
                "x": [190, 210, 210, 190],
                "y": [90, 90, 140, 140]
            },
            {  # Top-right
                "x": [90, 110, 110, 90],
                "y": [160, 160, 210, 210]
            },
            {  # Top-left
                "x": [190, 210, 210, 190],
                "y": [160, 160, 210, 210]
            },
        ]

        self.plot_data = ArrayPlotData(robot_x=self.robot_bounding_box['x'],
                                       robot_y=self.robot_bounding_box['y'],
                                       wheel_bl_x=self.robot_wheels[0]['x'],
                                       wheel_bl_y=self.robot_wheels[0]['y'],
                                       wheel_br_x=self.robot_wheels[1]['x'],
                                       wheel_br_y=self.robot_wheels[1]['y'],
                                       wheel_tr_x=self.robot_wheels[2]['x'],
                                       wheel_tr_y=self.robot_wheels[2]['y'],
                                       wheel_tl_x=self.robot_wheels[3]['x'],
                                       wheel_tl_y=self.robot_wheels[3]['y'],
                                       arrow_x=[0, 100, 200],
                                       arrow_y=[0, 100, 100],
                                       arrowhead_x=[150, 200],
                                       arrowhead_y=[150, 200])

        self.x_range = x_range
        self.y_range = y_range
        self.velocity_callback = velocity_callback

        velocity_tool = VelocityTool((150, 150), (300, 300),
                                     self.update_velocity, self.hover_velocity)

        # Show starting plot
        self.plot = self.plot_robot()
        self.plot.tools.append(velocity_tool)
        self.plot_velocity()
Ejemplo n.º 11
0
    def __init__(self, **traits):
        super(MYOGrapher, self).__init__(**traits)
        data_EMG = ArrayPlotData(x=[0],
                                 sEMG1=[0],
                                 sEMG2=[0],
                                 sEMG3=[0],
                                 sEMG4=[0],
                                 sEMG5=[0],
                                 sEMG6=[0],
                                 sEMG7=[0],
                                 sEMG8=[0])
        data_Angle = ArrayPlotData(x=[0], myo1=[0], myo2=[0])
        plot_Angle = Plot(data_Angle)
        plot_EMG = Plot(data_EMG)
        plot_EMG.plot(("x", "sEMG1"), type="line")
        plot_EMG.title = "sEMG"
        plot_EMG.value_scale = 'linear'
        plot_Angle.plot(("x", "myo1"), type="line")
        plot_Angle.title = "Angle"
        plot_Angle.value_scale = 'linear'

        self.plot_EMG = plot_EMG
        self.data_EMG = data_EMG
        self.plot_Angle = plot_Angle
        self.data_Angle = data_Angle
        self.sEMG_names = [
            'sEMG1', 'sEMG2', 'sEMG3', 'sEMG4', 'sEMG5', 'sEMG6', 'sEMG7',
            'sEMG8'
        ]
        self.Angle_names = ['myo1', 'myo2']
        self.emg_posit = 0
        self.angle_posit = 0
        _stream_emg = []
        _stream_angle = []

        for chanel in range(8):
            _stream_emg.append(np.zeros(self.sEMG_length))
        self.stream_emg = _stream_emg
        for _myos_in in range(2):
            _stream_angle.append(np.zeros(self.Angle_length))

        self.stream_emg = _stream_emg
        self.stream_Angle = _stream_angle
        self.EMG_StreamWin = np.zeros(self.window_size)
        self.Angle_StreamWin = np.zeros(self.window_size)
Ejemplo n.º 12
0
    def plot_clusters(self):
        '''
        Plots the clusters after calling the .fit method of the sklearn kmeans 
        estimator.
        '''

        self.kmeans.n_clusters = self.n_clusters
        self.kmeans.fit(self.dataset)

        # Reducing dimensions of the dataset and the cluster centers for
        # plottting
        pca = PCA(n_components=2, whiten=True)
        cluster_centers = pca.fit_transform(self.kmeans.cluster_centers_)
        dataset_red = pca.fit_transform(self.dataset)

        removed_components = []
        for component in self.container.components:
            removed_components.append(component)

        for component in removed_components:
            self.container.remove(component)

        for i in range(self.n_clusters):

            current_indices = find(self.kmeans.labels_ == i)
            current_data = dataset_red[current_indices, :]

            plotdata = ArrayPlotData(x=current_data[:, 0],
                                     y=current_data[:, 1])
            plot = Plot(plotdata)
            plot.plot(("x", "y"),
                      type='scatter',
                      color=tuple(COLOR_PALETTE[i]))
            self.container.add(plot)

        plotdata_cent = ArrayPlotData(x=cluster_centers[:, 0],
                                      y=cluster_centers[:, 1])
        plot_cent = Plot(plotdata_cent)
        plot_cent.plot(("x", "y"),
                       type='scatter',
                       marker='cross',
                       marker_size=8)
        self.container.add(plot_cent)

        self.container.request_redraw()
Ejemplo n.º 13
0
 def _plot_data_default(self):
     plot_data = ArrayPlotData(
         z_column_liquid=(
             self.active_anim_data.columnliqZ[:, :, self.time_slice]),
         z_bead_liquid=(self.active_anim_data.beadliqZ[:, :,
                                                       self.time_slice]),
         z_bead_bound=(self.active_anim_data.beadboundZ[:, :,
                                                        self.time_slice]))
     return plot_data
Ejemplo n.º 14
0
    def __init__(self, max_points=200, advance_time=False, *args, **kwargs):
        super(Viewer, self).__init__(*args, **kwargs)
        self.advance_time = advance_time
        self.max_points = Int(max_points)

        self.plotdata = ArrayPlotData(index=self.index)
        self.plotdata.set_data('y', self.data)
        self.plot = Plot(self.plotdata)
        self.plot.plot(('index', 'y'), type='line', color='blue')
Ejemplo n.º 15
0
    def _plot_default(self):
        x = np.linspace(-14, 14, 100)
        y = np.sin(x) * x**3
        plotdata = ArrayPlotData(x=x, y=y)

        plot = Plot(plotdata)
        plot.plot(('x', 'y'), type='line', color='blue')
        plot.title = 'sin(x) * x^3'
        return plot
Ejemplo n.º 16
0
 def _create_line_plot(self):
     line_data = ArrayPlotData(current=np.array(()), frequency=np.array(()),)
     plot = Plot(line_data, padding=8, padding_left=64, padding_bottom=36)
     plot.plot(('current','frequency'), color='blue', name='zeeman')
     plot.index_axis.title = 'current [mA]'
     plot.value_axis.title = 'frequency [MHz]'
     plot.tools.append(SaveTool(plot))
     self.line_data = line_data
     self.line_plot = plot
Ejemplo n.º 17
0
 def _plot_data_default(self):
     plot_data = ArrayPlotData()
     plot_data.set_data('distance', np.zeros(50))
     plot_data.set_data('potentiometer', np.zeros(50))
     plot_data.set_data('switch', np.zeros(50))
     plot_data.set_data('acc_x', np.zeros(50))
     plot_data.set_data('acc_y', np.zeros(50))
     plot_data.set_data('acc_z', np.zeros(50))
     return plot_data
Ejemplo n.º 18
0
def _create_plot_component():

    # Generate some data for the eye diagram.
    num_samples = 5000
    samples_per_symbol = 24
    y = demo_data(num_samples, samples_per_symbol)

    # Compute the eye diagram array.
    ybounds = (-0.25, 1.25)
    grid = grid_count(y,
                      2 * samples_per_symbol,
                      offset=16,
                      size=(480, 480),
                      bounds=ybounds).T

    # Convert the array to floating point, and replace 0 with np.nan.
    # These points will be transparent in the image plot.
    grid = grid.astype(np.float32)
    grid[grid == 0] = np.nan

    #---------------------------------------------------------------------
    # The rest of the function creates the chaco image plot.

    pd = ArrayPlotData()
    pd.set_data("eyediagram", grid)

    plot = Plot(pd)
    img_plot = plot.img_plot("eyediagram",
                             xbounds=(0, 2),
                             ybounds=ybounds,
                             bgcolor=(0, 0, 0),
                             colormap=cool)[0]

    # Tweak some of the plot properties
    plot.title = "Eye Diagram"
    plot.padding = 50

    # Axis grids
    vgrid = PlotGrid(component=plot,
                     mapper=plot.index_mapper,
                     orientation='vertical',
                     line_color='gray',
                     line_style='dot')
    hgrid = PlotGrid(component=plot,
                     mapper=plot.value_mapper,
                     orientation='horizontal',
                     line_color='gray',
                     line_style='dot')
    plot.underlays.append(vgrid)
    plot.underlays.append(hgrid)

    # Add pan and zoom tools.
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False)
    img_plot.overlays.append(zoom)

    return plot
Ejemplo n.º 19
0
    def _image_plot_default(self):
        '''
        Default chaco plot object for the image plot.
        '''

        self.img_plotdata = ArrayPlotData(imagedata=self.table)
        p = Plot(self.img_plotdata)
        p.img_plot('imagedata')
        return p
Ejemplo n.º 20
0
 def _pd_default(self):
     image = ones(shape=(300, 400))
     pd = ArrayPlotData()
     pd.set_data("imagedata", image)
     pd.set_data('h_index', numpy.arange(400))
     pd.set_data('h_value', numpy.ones((400, )))
     pd.set_data('v_index', numpy.arange(300))
     pd.set_data('v_value', numpy.ones((300, )))
     return pd
Ejemplo n.º 21
0
    def test_plot_from_unsupported_array_shape(self):
        arr = arange(8).reshape(2, 2, 2)
        data = ArrayPlotData(x=arr, y=arr)
        plot = Plot(data)
        self.assertRaises(ValueError, plot.plot, ("x", "y"))

        arr = arange(16).reshape(2, 2, 2, 2)
        data.update_data(x=arr, y=arr)
        self.assertRaises(ValueError, plot.plot, ("x", "y"))
Ejemplo n.º 22
0
 def _plot_default(self):
     x = np.linspace(0, 10, 51)
     y = np.linspace(0, 5, 51)
     X, Y = np.meshgrid(x, y)
     z = np.exp(-(X**2 + Y**2) / 100)
     plotdata = ArrayPlotData(zdata=z[:-1, :-1])
     plot = Plot(plotdata)
     plot.img_plot("zdata", xbounds=x, ybounds=y, colormap=jet)
     return plot
Ejemplo n.º 23
0
    def _plot_default(self):
        """
        Construct the default plot container, data source and image plot
        """
        self.plotdata = ArrayPlotData(imagedata=self.datamodel.data.T)
        plot = Plot(self.plotdata)
        img_plot = plot.img_plot("imagedata", colormap=jet, origin='top left')

        return plot
Ejemplo n.º 24
0
    def __init__(self, link):
        super(SolutionView, self).__init__()

        self.log_file = None
        self.vel_log_file = None

        self.plot_data = ArrayPlotData(lat=[0.0],
                                       lng=[0.0],
                                       alt=[0.0],
                                       t=[0.0],
                                       ref_lat=[0.0],
                                       ref_lng=[0.0],
                                       region_lat=[0.0],
                                       region_lng=[0.0])
        self.plot = Plot(self.plot_data)

        self.plot.plot(('lng', 'lat'),
                       type='line',
                       name='line',
                       color=(0, 0, 0, 0.1))
        self.plot.plot(('lng', 'lat'),
                       type='scatter',
                       name='points',
                       color='blue',
                       marker='dot',
                       line_width=0.0,
                       marker_size=1.0)

        self.plot.index_axis.tick_label_position = 'inside'
        self.plot.index_axis.tick_label_color = 'gray'
        self.plot.index_axis.tick_color = 'gray'
        self.plot.value_axis.tick_label_position = 'inside'
        self.plot.value_axis.tick_label_color = 'gray'
        self.plot.value_axis.tick_color = 'gray'
        self.plot.padding = (0, 1, 0, 1)

        self.plot.tools.append(PanTool(self.plot))
        zt = ZoomTool(self.plot,
                      zoom_factor=1.1,
                      tool_mode="box",
                      always_on=False)
        self.plot.overlays.append(zt)

        self.link = link
        self.link.add_callback(sbp_messages.SBP_POS_LLH,
                               self._pos_llh_callback)
        self.link.add_callback(sbp_messages.SBP_VEL_NED, self.vel_ned_callback)
        self.link.add_callback(sbp_messages.SBP_DOPS, self.dops_callback)
        self.link.add_callback(sbp_messages.SBP_GPS_TIME,
                               self.gps_time_callback)

        self.week = None
        self.nsec = 0

        self.python_console_cmds = {
            'solution': self,
        }
Ejemplo n.º 25
0
    def __init__(self, x, all_agents):

        self.x = x
        self.all_agents = all_agents
        self.plotdata = ArrayPlotData(imagedata=self.x)
        plot = Plot(self.plotdata)
        plot.img_plot('imagedata')
        self.plot = plot
        self.sim_count = 0
Ejemplo n.º 26
0
 def _plot_default(self):
     import numpy as np
     data = np.random.normal(size=(10, 2))
     apl = ArrayPlotData(x=data[:, 0], y=data[:, 1])
     plot = Plot(apl)
     scatter = plot.plot(('x', 'y'), type='scatter')[0]
     self.inspector = ScatterInspector(scatter)
     scatter.tools.append(self.inspector)
     return plot
    def test_add_curve(self):
        plot_data = ArrayPlotData()
        plot_data.set_data("x_curve", [])
        plot_data.set_data("y_curve", [])
        plot = ChacoPlot(plot_data)

        self.plot._add_curve(plot)
        self.assertEqual(1, len(self.plot._sub_axes))
        self.assertIn('curve_plot', self.plot._sub_axes)
def _create_plot_component(obj, cqtkernel):
    # Scale plot
    scale_data = zeros((OCTAVES * BINS, FRAMES_PER_PLOT))
    obj.scale_plotdata = ArrayPlotData()
    obj.scale_plotdata.set_data('scaleimagedata', scale_data)
    scale_plot = Plot(obj.scale_plotdata)
    max_time = float(FRAMES_PER_PLOT * 2**(OCTAVES-1) * cqtkernel.FFTLen) / SAMPLING_RATE
    max_note_index = OCTAVES * BINS
    scale_plot.img_plot('scaleimagedata', 
                        name = 'Scale',
                        xbounds=(0, max_time),
                        ybounds=(0, max_note_index),
                        colormap=hot,
                        )
    scale_range = scale_plot.plots['Scale'][0].value_mapper.range
    scale_range.high = 5
    scale_range.low = 0.0
    scale_plot.title = 'Scale'
    obj.scale_plot = scale_plot

    # CQT plot
    cqt_data = zeros((OCTAVES * BINS, FRAMES_PER_PLOT))
    obj.cqt_plotdata = ArrayPlotData()
    obj.cqt_plotdata.set_data('cqtimagedata', cqt_data)
    cqt_plot = Plot(obj.cqt_plotdata)
    max_time = float(FRAMES_PER_PLOT * 2**(OCTAVES-1) * cqtkernel.FFTLen) / SAMPLING_RATE
    max_note_index = OCTAVES * BINS
    cqt_plot.img_plot('cqtimagedata', 
                        name = 'CQT',
                        xbounds=(0, max_time),
                        ybounds=(0, max_note_index),
                        colormap=hot,
                        )
    cqt_range = cqt_plot.plots['CQT'][0].value_mapper.range
    cqt_range.high = 5
    cqt_range.low = 0.0
    cqt_plot.title = 'CQT'
    obj.cqt_plot = cqt_plot

    container = HPlotContainer()
    container.add(obj.scale_plot)
    container.add(obj.cqt_plot)

    return container
Ejemplo n.º 29
0
def _create_plot_component(obj):
    # Setup the xaxis plot
    frequencies = linspace(0.0, float(SAMPLING_RATE) / 2, num=NUM_SAMPLES / 2)
    obj.spectrum_data = ArrayPlotData(frequency=frequencies)
    empty_amplitude = zeros(NUM_SAMPLES / 2)
    obj.spectrum_data.set_data('amplitude', empty_amplitude)

    obj.spectrum_plot = Plot(obj.spectrum_data)
    obj.spectrum_plot.plot(("frequency", "amplitude"),
                           name="Spectrum",
                           color="red")
    obj.spectrum_plot.padding = 50
    obj.spectrum_plot.title = "Spectrum"
    spec_range = obj.spectrum_plot.plots.values()[0][0].value_mapper.range
    spec_range.low = 0.0
    spec_range.high = 5.0
    obj.spectrum_plot.index_axis.title = 'Frequency (Hz)'
    obj.spectrum_plot.value_axis.title = 'Amplitude'

    # Setup yaxis 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

    container = HPlotContainer()
    container.add(obj.spectrum_plot)
    container.add(obj.spectrogram_plot)

    return container
Ejemplo n.º 30
0
    def _create_plot(self):
        plot_data = ArrayPlotData(image=self.image)
        plot = Plot(plot_data,
                    width=500,
                    height=500,
                    resizable='hv',
                    aspect_ratio=1.0,
                    padding=8,
                    padding_left=32,
                    padding_bottom=32)
        plot.img_plot('image',
                      colormap=RdBu_r,
                      xbounds=(self.X[0], self.X[-1]),
                      ybounds=(self.Y[0], self.Y[-1]),
                      name='image')
        image = plot.plots['image'][0]
        image.x_mapper.domain_limits = (self.imager.get_x_range()[0],
                                        self.imager.get_x_range()[1])
        image.y_mapper.domain_limits = (self.imager.get_y_range()[0],
                                        self.imager.get_y_range()[1])
        zoom = AspectZoomTool(image, enable_wheel=False)
        cursor = CursorTool2D(image,
                              drag_button='left',
                              color='yellow',
                              marker_size=1.0,
                              line_width=1.0)
        image.overlays.append(cursor)
        image.overlays.append(zoom)
        colormap = image.color_mapper
        colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
                            color_mapper=colormap,
                            plot=plot,
                            orientation='v',
                            resizable='v',
                            width=16,
                            height=320,
                            padding=8,
                            padding_left=32)
        container = HPlotContainer()
        container.add(plot)
        container.add(colorbar)
        z_label = PlotLabel(text='z=0.0',
                            color='red',
                            hjustify='left',
                            vjustify='bottom',
                            position=[10, 10])
        container.overlays.append(z_label)
        container.tools.append(SaveTool(container))

        self.plot_data = plot_data
        self.scan_plot = image
        self.cursor = cursor
        self.zoom = zoom
        self.figure = plot
        self.figure_container = container
        self.sync_trait('z_label_text', z_label, 'text')