Example #1
0
    def draw_one(self, idx, ap):
        canvas = self.canvas[idx]
        print 'canvas=',canvas

        # Generate some Data
        x_data = [ i for i in range(1,100) ]
        y_data = self.y_datas[idx]
        y_data.append(ap.get_sta_num())
        if len(y_data) > 100:
            del y_data[0]

        # most items require data as a list of (x, y) pairs:
        #    [[1x, y1], [x2, y2], [x3, y3], ..., [xn, yn]]
        xy_data = list(zip(x_data, y_data))

        # Create your Poly object(s).
        # Use keyword args to set display properties.
        line = wxplot.PolySpline(
            xy_data,
            colour=wx.Colour(128, 128, 0),   # Color: olive
            width=3,
        )

        # create your graphics object
        graphics = wxplot.PlotGraphics([line])
        # draw the graphics object on the canvas
        canvas.Draw(graphics)
    def __init__(self):
        wx.Frame.__init__(self,
                          None,
                          title="Example of wx.lib.plot",
                          size=(640, 480))

        # Generate some Data
        x_data = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        y_data = [2, 4, 6, 4, 2, 5, 6, 7, 1]

        # most items require data as a list of (x, y) pairs:
        #    [[1x, y1], [x2, y2], [x3, y3], ..., [xn, yn]]
        xy_data = list(zip(x_data, y_data))

        # Create your Poly object(s).
        # Use keyword args to set display properties.
        line = wxplot.PolySpline(
            xy_data,
            colour=wx.Colour(128, 128, 0),  # Color: olive
            width=3,
        )

        # create your graphics object
        graphics = wxplot.PlotGraphics([line])

        # create your canvas
        panel = wxplot.PlotCanvas(self)

        # Edit panel-wide settings
        axes_pen = wx.Pen(wx.BLUE, 1, wx.PENSTYLE_LONG_DASH)
        panel.axesPen = axes_pen

        # draw the graphics object on the canvas
        panel.Draw(graphics)
Example #3
0
    def plot(self, xx, yy):
        # Generate some Data
        x_data = xx
        y_data = yy

        # most items require data as a list of (x, y) pairs:
        #    [[1x, y1], [x2, y2], [x3, y3], ..., [xn, yn]]
        xy_data = list(zip(x_data, y_data))

        # Create your Poly object(s).
        # Use keyword args to set display properties.
        line = wxplot.PolySpline(
            xy_data,
            colour=wx.Colour(128, 128, 0),  # Color: olive
            width=1,
        )

        # create your graphics object
        graphics = wxplot.PlotGraphics([line])
        self.panel.xSpec = (50.0, 125.0)
        self.panel.ySpec = (3000.0, 1000.0)
        # draw the graphics object on the canvas
        self.panel.Draw(graphics)


# if __name__ == '__main__':
#     app = wx.App()
#     frame = PlotExample()
#     frame.Show()
#     app.MainLoop()
Example #4
0
def _draw2Objects():
    """Sin, Cos, Points, and lines between points"""
    # 100 points sin function, plotted as green dots
    data1 = 2. * np.pi * np.arange(200) / 200.
    data1.shape = (100, 2)
    data1[:, 1] = np.sin(data1[:, 0])
    line1 = wxplot.PolySpline(data1,
                              legend='Green Line',
                              colour='green',
                              width=6,
                              style=wx.PENSTYLE_DOT)

    # 25 points cos function, plotted as red dot-dash with steps.
    data1 = 2. * np.pi * np.arange(50) / 50.
    data1.shape = (25, 2)
    data1[:, 1] = np.cos(data1[:, 0])
    line2 = wxplot.PolyLine(
        data1,
        legend='Red Line',
        colour='red',
        width=2,
        style=wx.PENSTYLE_DOT_DASH,
        drawstyle='steps-post',
    )

    # data points for the 25pt cos function.
    pts2 = wxplot.PolyMarker(
        data1,
        legend='Red Points',
        colour='red',
        size=1.5,
    )

    # A few more points...
    pi = np.pi
    pts = [(0., 0.), (pi / 4., 1.), (pi / 2, 0.), (3. * pi / 4., -1)]
    markers1 = wxplot.PolyMarker(
        pts,
        legend='Cross Hatch Square',
        colour='blue',
        width=3,
        size=6,
        fillcolour='red',
        fillstyle=wx.CROSSDIAG_HATCH,
        marker='square',
    )
    marker_line = wxplot.PolyLine(
        pts,
        legend='Cross Hatch Square',
        colour='blue',
        width=3,
    )

    return wxplot.PlotGraphics([markers1, line1, line2, pts2, marker_line],
                               "Big Markers with Different Line Styles")
Example #5
0
def MyDataObject():
    # 50 个点的sin函数,用蓝色圆点表示
    data1 = 2. * numpy.pi * numpy.arange(100) / 100.
    data1.shape = (50, 2)
    data1[:, 1] = numpy.sin(data1[:, 0])
    markers = wxPyPlot.PolyMarker(data1, legend='Green Markers', colour='blue', marker='circle', size=1)

    # 50个点的cos函数,用红色表示
    data2 = 2. * numpy.pi * numpy.arange(100) / 100.
    data2.shape = (50, 2)
    data2[:, 1] = numpy.cos(data2[:, 0])
    lines = wxPyPlot.PolySpline(data2, legend='Red Line', colour='red')

    GraphTitle = "Plot Data(Sin and Cos)"

    return wxPyPlot.PlotGraphics([markers, lines], GraphTitle, "X Axis", "Y Axis")
Example #6
0
def _draw1Objects():
    """Sin, Cos, and Points"""
    # 100 points sin function, plotted as green circles
    data1 = 2. * np.pi * np.arange(-200, 200) / 200.
    data1.shape = (200, 2)
    data1[:, 1] = np.sin(data1[:, 0])
    markers1 = wxplot.PolyMarker(
        data1,
        legend='Green Markers',
        colour='green',
        marker='circle',
        size=1,
    )

    # 50 points cos function, plotted as red line and markers
    data1 = 2. * np.pi * np.arange(-100, 100) / 100.
    data1.shape = (100, 2)
    data1[:, 1] = np.cos(data1[:, 0])
    lines = wxplot.PolySpline(data1, legend='Red Line', colour='red')
    markers3 = wxplot.PolyMarker(
        data1,
        legend='Red Dot',
        colour='red',
        marker='circle',
        size=1,
    )

    # A few more points...
    pi = np.pi
    pts = [(0., 0.), (pi / 4., 1.), (pi / 2, 0.), (3. * pi / 4., -1)]
    markers2 = wxplot.PolyMarker(
        pts,
        legend='Cross Legend',
        colour='blue',
        marker='cross',
    )
    line2 = wxplot.PolyLine(pts, drawstyle='steps-post')

    return wxplot.PlotGraphics(
        [markers1, lines, markers3, markers2, line2],
        "Graph Title",
        "X Axis",
        "Y Axis",
    )