Beispiel #1
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))
def _create_plot_component():

    # Create some x-y data series to plot
    plot_area = OverlayPlotContainer(border_visible=True)
    container = HPlotContainer(padding=50, bgcolor="transparent")
    #container.spacing = 15

    x = linspace(-2.0, 10.0, 100)
    for i in range(5):
        color = tuple(COLOR_PALETTE[i])
        y = jn(i, x)
        renderer = create_line_plot((x, y), color=color)
        plot_area.add(renderer)
        #plot_area.padding_left = 20

        axis = PlotAxis(
            orientation="left",
            resizable="v",
            mapper=renderer.y_mapper,
            axis_line_color=color,
            tick_color=color,
            tick_label_color=color,
            title_color=color,
            bgcolor="transparent",
            title="jn_%d" % i,
            border_visible=True,
        )
        axis.bounds = [60, 0]
        axis.padding_left = 10
        axis.padding_right = 10

        container.add(axis)

        if i == 4:
            # Use the last plot's X mapper to create an X axis and a
            # vertical grid
            x_axis = PlotAxis(orientation="bottom",
                              component=renderer,
                              mapper=renderer.x_mapper)
            renderer.overlays.append(x_axis)
            grid = PlotGrid(mapper=renderer.x_mapper,
                            orientation="vertical",
                            line_color="lightgray",
                            line_style="dot")
            renderer.underlays.append(grid)

    # Add the plot_area to the horizontal container
    container.add(plot_area)

    # Attach some tools to the plot
    broadcaster = BroadcasterTool()
    for plot in plot_area.components:
        broadcaster.tools.append(PanTool(plot))

    # Attach the broadcaster to one of the plots.  The choice of which
    # plot doesn't really matter, as long as one of them has a reference
    # to the tool and will hand events to it.
    plot.tools.append(broadcaster)

    return container
Beispiel #3
0
def _create_plot_component():

    # Create some x-y data series to plot
    plot_area = OverlayPlotContainer(border_visible=True)
    container = HPlotContainer(padding=50, bgcolor="transparent")
    #container.spacing = 15

    x = linspace(-2.0, 10.0, 100)
    for i in range(5):
        color = tuple(COLOR_PALETTE[i])
        y = jn(i, x)
        renderer = create_line_plot((x, y), color=color)
        plot_area.add(renderer)
        #plot_area.padding_left = 20

        axis = PlotAxis(orientation="left", resizable="v",
                    mapper = renderer.y_mapper,
                    axis_line_color=color,
                    tick_color=color,
                    tick_label_color=color,
                    title_color=color,
                    bgcolor="transparent",
                    title = "jn_%d" % i,
                    border_visible = True,)
        axis.bounds = [60,0]
        axis.padding_left = 10
        axis.padding_right = 10

        container.add(axis)

        if i == 4:
            # Use the last plot's X mapper to create an X axis and a
            # vertical grid
            x_axis = PlotAxis(orientation="bottom", component=renderer,
                        mapper=renderer.x_mapper)
            renderer.overlays.append(x_axis)
            grid = PlotGrid(mapper=renderer.x_mapper, orientation="vertical",
                    line_color="lightgray", line_style="dot")
            renderer.underlays.append(grid)

    # Add the plot_area to the horizontal container
    container.add(plot_area)

    # Attach some tools to the plot
    broadcaster = BroadcasterTool()
    for plot in plot_area.components:
        broadcaster.tools.append(PanTool(plot))

    # Attach the broadcaster to one of the plots.  The choice of which
    # plot doesn't really matter, as long as one of them has a reference
    # to the tool and will hand events to it.
    plot.tools.append(broadcaster)

    return container
Beispiel #4
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))