コード例 #1
0
    def _setup_plot_tools(self, plot):
        """Sets up the background, and several tools on a plot"""
        # Make a white background with grids and axes
        plot.bgcolor = "white"
        add_default_grids(plot)
        add_default_axes(plot)

        # Allow white space around plot
        plot.index_range.tight_bounds = False
        plot.index_range.refresh()
        plot.value_range.tight_bounds = False
        plot.value_range.refresh()

        # The PanTool allows panning around the plot
        plot.tools.append(PanTool(plot))

        # The ZoomTool tool is stateful and allows drawing a zoom
        # box to select a zoom region.
        zoom = ZoomTool(plot, tool_mode="box", always_on=False)
        plot.overlays.append(zoom)

        # The DragZoom tool just zooms in and out as the user drags
        # the mouse vertically.
        dragzoom = DragZoom(plot, drag_button="right")
        plot.tools.append(dragzoom)

        # Add a legend in the upper right corner, and make it relocatable
        legend = Legend(component=plot, padding=10, align="ur")
        legend.tools.append(LegendTool(legend, drag_button="right"))
        plot.overlays.append(legend)

        return plot.value_mapper, plot.index_mapper, legend
コード例 #2
0
 def __init__(self):
     # Create the data and the PlotData object
     x = linspace(-14, 14, 500)
     y = sin(x) * x**3
     plotdata = ArrayPlotData(x=x, y=y)
     # Create a Plot and associate it with the PlotData
     plot = Plot(plotdata)
     # Create a line plot in the Plot
     plot.plot(("x", "y"), type="line", color="blue")
     # Add the pan and zoom tools
     plot.tools.append(PanTool(plot))
     plot.tools.append(ZoomTool(plot))
     plot.tools.append(DragZoom(plot, drag_button="right"))
     self.plot = plot
コード例 #3
0
    def __init__(self):
        super(ToolsExample1, self).__init__()
        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")

        #append tools to pan, zoom, and drag
        plot.tools.append(PanTool(plot))
        plot.tools.append(ZoomTool(plot))
        plot.tools.append(DragZoom(plot, drag_button="right"))

        self.plot = plot
コード例 #4
0
    def _plot_default(self):
        """ This creates the default value for the plot.
        """
        # create the main plot object
        plot = Plot(self.plot_data)

        plot.plot(('x', 'y'), type='line', name='raw data', color='lightgreen')

        # add the additional information
        plot.title = 'Row Data'
        plot.x_axis.title = 'Samples'
        plot.y_axis.title = 'Amplitude'

        # tools for basic interactivity
        plot.tools.append(PanTool(plot))
        plot.tools.append(ZoomTool(plot))
        plot.tools.append(DragZoom(plot, drag_button="right"))

        return plot
コード例 #5
0
    def add(self, series, limit=None):

        broadcaster = BroadcasterTool()

        for name, line in series._plot.line.items():
            if limit is not None and name not in limit:
                continue
            if line.time == []:
                print "Graph.add> empty:", name
                continue
            plot = create_line_plot((seconds(line.time), line.data),
                                    color=line.color)
            self.plot_area.add(plot)

            axis = PlotAxis(
                orientation="left",
                resizable="v",
                mapper=plot.y_mapper,
                bgcolor="white",
                title=name,
                title_color=line.color,
                title_spacing=-4.0,
                border_visible=True,
            )
            ## Visual style
            axis.bounds = [60, 0]
            axis.padding_left = 1
            axis.padding_right = 1
            self.container.add(axis)

            ## Tools (attach to all for now)
            plot.tools.append(broadcaster)
            broadcaster.tools.append(PanTool(plot))
            broadcaster.tools.append(
                DragZoom(plot,
                         maintain_aspect_ratio=False,
                         drag_button='right',
                         restrict_domain=True))
コード例 #6
0
    def _plot_default(self):
        """ This creates the default value for the plot.
        """
        # create the main plot object
        plot = Plot(self.plot_data)

        renderer = plot.plot(('index', 'value', 'color'), \
                             type="cmap_scatter", \
                             color_mapper=jet, \
                             marker='triangle'
                             )[0]

        self.renderer = renderer

        # inspector tool for showing data about points
        #renderer.tools.append(ScatterInspector(renderer))

        # overlay for highlighting selected points
        overlay = ScatterInspectorOverlay(renderer,
                                          hover_color="red",
                                          hover_marker_size=6,
                                          selection_marker_size=6,
                                          selection_color="yellow",
                                          selection_outline_color="black",
                                          selection_line_width=3)
        renderer.overlays.append(overlay)

        # add the additional information
        plot.title = 'Parameters Data'
        plot.x_axis.title = ''
        plot.y_axis.title = ''

        # tools for basic interactivity
        plot.tools.append(PanTool(plot))
        plot.tools.append(ZoomTool(plot))
        plot.tools.append(DragZoom(plot, drag_button="right"))

        return plot