Beispiel #1
0
    def _plot_default(self):
        # Create a GridContainer to hold all of our plots: 2 rows, 3 columns
        container = GridPlotContainer(shape=(2, 3),
                                      spacing=(10, 5),
                                      valign='top',
                                      bgcolor='lightgray')

        # Create x data
        x = linspace(-5, 15.0, 100)
        pd = ArrayPlotData(index=x)

        # Plot some Bessel functions and add the plots to our container
        for i in range(6):
            data_name = 'y{}'.format(i)
            pd.set_data(data_name, jn(i, x))

            plot = Plot(pd)
            plot.plot(('index', data_name),
                      color=COLOR_PALETTE[i],
                      line_width=3.0)

            # Set each plot's aspect based on its position in the grid
            plot.height = ((i % 3) + 1) * 50.0
            plot.resizable = 'h'

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

        return container
Beispiel #2
0
 def _v_plot_default(self):
     plot = Plot(self.pd,
                 orientation="v",
                 resizable="v",
                 padding=20,
                 padding_bottom=160,
                 default_origin="top left")
     plot.height = 600
     plot.width = 100
     plot.plot(("v_index", "v_value"))
     return plot
Beispiel #3
0
 def _h_plot_default(self):
     plot = Plot(self.pd, resizable="h")
     plot.height = 100
     plot.padding = 20
     plot.plot(("h_index", "h_value"))
     return plot
Beispiel #4
0
    def _brain_default(self):
        plot = Plot(self.brain_data, padding=0)
        plot.width = self.brain_voxels.shape[1]
        plot.height = self.brain_voxels.shape[0]
        plot.aspect_ratio = 1.
        plot.index_axis.visible = False
        plot.value_axis.visible = False
        renderer = plot.img_plot("axial", colormap=gray)[0]
        plot.color_mapper.range = DataRange1D(low=0., high=1.0)
        plot.bgcolor = 'pink'

        # Brain tools
        plot.tools.append(PanTool(plot, drag_button="right"))
        plot.tools.append(ZoomTool(plot))
        imgtool = ImageInspectorTool(renderer)
        renderer.tools.append(imgtool)
        overlay = ImageInspectorOverlay(component=renderer, image_inspector=imgtool,
                                        bgcolor="white", border_visible=True)
        renderer.overlays.append(overlay)

        # Brain track cursor
        self.cursor = CursorTool2D(renderer, drag_button='left', color='red', line_width=2.0)
        #self.cursor.on_trait_change(self.update_stackedhist, 'current_index')
        self.cursor.current_positionyou = (0., 0.)
        renderer.overlays.append(self.cursor)

        # Brain colorbar
        colormap = plot.color_mapper
        colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
                            color_mapper=colormap,
                            plot=plot,
                            orientation='v',
                            resizable='v',
                            width=20,
                            padding=(30, 0, 0, 0))
        colorbar.padding_top = plot.padding_top
        colorbar.padding_bottom = plot.padding_bottom

        # Noisy brain
        plot2 = Plot(self.brain_data, padding=0)
        plot2.width = self.brain_voxels.shape[1]
        plot2.height = self.brain_voxels.shape[0]
        plot2.aspect_ratio = 1.
        plot2.index_axis.visible = False
        plot2.value_axis.visible = False
        renderer2 = plot2.img_plot("noisy_axial", colormap=gray)[0]
        plot2.color_mapper.range = DataRange1D(low=0., high=1.0)
        plot2.bgcolor = 'pink'
        plot2.range2d = plot.range2d

        # Brain_map tools
        plot2.tools.append(PanTool(plot2, drag_button="right"))
        plot2.tools.append(ZoomTool(plot2))
        imgtool2 = ImageInspectorTool(renderer2)
        renderer2.tools.append(imgtool2)
        overlay2 = ImageInspectorOverlay(component=renderer2, image_inspector=imgtool2,
                                         bgcolor="white", border_visible=True)
        renderer2.overlays.append(overlay2)

        # Brain_map track cursor
        self.cursor2 = CursorTool2D(renderer2, drag_button='left', color='red', line_width=2.0)
        #self.cursor2.on_trait_change(self.cursor2_changed, 'current_index')
        self.cursor2.current_position = (0., 0.)
        renderer2.overlays.append(self.cursor2)

        # Brain_map colorbar
        colormap2 = plot2.color_mapper
        colorbar2 = ColorBar(index_mapper=LinearMapper(range=colormap2.range),
                             color_mapper=colormap2,
                             plot=plot2,
                             orientation='v',
                             resizable='v',
                             width=20,
                             padding=(30, 0, 0, 0))
        colorbar2.padding_top = plot2.padding_top
        colorbar2.padding_bottom = plot2.padding_bottom

        # Create a container to position the plot and the colorbar side-by-side
        container = HPlotContainer(use_backbuffer=True, padding=(0, 0, 10, 10))
        container.add(plot)
        container.add(colorbar)
        container.bgcolor = "lightgray"

        container2 = HPlotContainer(use_backbuffer=True, padding=(0, 0, 10, 10))
        container2.add(plot2)
        container2.add(colorbar2)
        container2.bgcolor = "lightgray"

        Hcontainer = HPlotContainer(use_backbuffer=True)
        Hcontainer.add(container)
        Hcontainer.add(container2)
        Hcontainer.bgcolor = "lightgray"

        return Hcontainer
Beispiel #5
0
def _create_plot_component():
    army_lat = np.column_stack([army['start_lat'],
                                army['end_lat']]).reshape(-1)
    army_lon = np.column_stack([army['start_lon'],
                                army['end_lon']]).reshape(-1)

    plot_data = ArrayPlotData(
        army_lon=army_lon,
        army_lat=army_lat,
        army_size=army['size'],
        army_color=army['direction'] * army["group"],
        towns_lat=towns['lat'],
        towns_lon=towns['lon'],
        towns=towns['town'],
        temp_lon=temperatures['lon'],
        temp=temperatures['temp'],
        temp_date=temperatures['date'],
    )

    map_plot = Plot(plot_data)
    map_plot.x_grid = None
    map_plot.y_grid = None
    map_plot.x_axis.orientation = 'top'
    map_plot.x_axis.title = 'Longitude'
    map_plot.y_axis.title = 'Latitude'
    map_plot.title = "Minard's Map of Napoleon's Russian Campaign"
    map_plot._title.overlay_position = "inside top"
    map_plot._title.hjustify = "left"
    map_plot._title.vjustify = "bottom"
    map_plot.plot(
        ("army_lon", "army_lat", "army_color", "army_size"),
        type="cmap_segment",
        name="my_plot",
        color_mapper=viridis,
        border_visible=True,
        bgcolor="white",
        size_min=1.0,
        size_max=128.0,
    )
    map_plot.plot(
        ("towns_lon", "towns_lat"),
        type="scatter",
    )
    map_plot.plot(
        ("towns_lon", "towns_lat", "towns"),
        type="text",
        text_margin=4,
        h_position='right',
        text_offset=(4, 0),
    )
    map_plot.plot_1d(
        ('temp_lon'),
        type='line_scatter_1d',
        alpha=0.5,
        line_style='dot',
    )
    map_plot.index_range.high_setting = 38
    map_plot.index_range.low_setting = 23
    map_plot.value_range.high_setting = 56.0
    map_plot.value_range.low_setting = 53.5
    map_plot.tools.extend([
        PanTool(map_plot),
        ZoomTool(map_plot),
    ])

    temp_plot = Plot(plot_data, height=100)
    temp_plot.index_range = map_plot.index_range
    temp_plot.x_grid = None
    temp_plot.x_axis = None
    temp_plot.y_axis.orientation = 'right'
    temp_plot.y_axis.title = u'Temp (°Re)'
    temp_plot.plot(
        ('temp_lon', 'temp'),
        type='line',
    )
    temp_plot.plot_1d(
        ('temp_lon'),
        type='line_scatter_1d',
        alpha=0.5,
        line_style='dot',
    )
    temp_plot.plot_1d(
        ('temp_lon', 'temp_date'),
        type='textplot_1d',
        alpha=0.5,
        line_style='dot',
        alignment='bottom',
    )
    temp_plot.value_range.high_setting = 5
    temp_plot.value_range.low_setting = -35

    container = VPlotContainer(temp_plot, map_plot)
    container.spacing = 0
    map_plot.padding_bottom = 0
    map_plot.padding_left = 70
    map_plot.padding_right = 70
    map_plot.padding_top = 50
    temp_plot.padding_top = 0
    temp_plot.padding_bottom = 15
    temp_plot.padding_right = 70
    temp_plot.padding_left = 70
    temp_plot.height = 100
    temp_plot.resizable = 'h'

    return container