コード例 #1
0
    def __init__(self):
        super(LinePlot, self).__init__()
        x = linspace(-14, 14, 100)
        y1 = sin(x) * x**3
        y2 = cos(x) * x**3
        plotdata = ArrayPlotData(x=x, y1=y1, y2=y2)
        plot = Plot(plotdata)
        plot.plot(("x", "y1"), type="line", color="blue", name="sin(x) * x**3")
        plot.plot(("x", "y2"), type="line", color="red", name="cos(x) * x**3")
        plot.plot(("x", "y2"),
                  type="scatter",
                  color="red",
                  marker="circle",
                  marker_size=2,
                  name="cos(x) * x**3 points")
        plot.title = "Multiple Curves"
        self.plot = plot

        legend = Legend(padding=10, align="ur")
        legend.plots = plot.plots
        plot.overlays.append(legend)
コード例 #2
0
    def __init__(self, parent, id=-1, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.statusBar = self.GetTopLevelParent().statusBar

        self.container = OverlayPlotContainer(padding = 50, fill_padding = True,
            bgcolor = "lightgray", use_backbuffer=True)
        self.legend = Legend(component=self.container, padding=10, align="ur")
        #self.legend.tools.append(LegendTool(self.legend, drag_button="right"))
        self.container.overlays.append(self.legend)

        self.plot_window = Window(self, component=self.container)

        self.container.tools.append(TraitsTool(self.container))

        self.firstplot = True
        self._palette = ['red', 'blue', 'green', 'purple', 'yellow']
        self._current_palette_index = 0

        self._traces = []

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.plot_window.control, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)