예제 #1
0
    def __init__(self, data, origData, yieldCurve):
        self.frame1 = wx.Frame(None, title="Analyttlic", id=-1, size=(800, 600))
        self.panel1 = wx.Panel(self.frame1)
        #self.panel1.SetBackgroundColour("yellow")

        # mild difference between wxPython26 and wxPython28
        if wx.VERSION[1] < 7:
            plotter = plot.PlotCanvas(self.panel1, size=(800, 600))
        else:
            plotter = plot.PlotCanvas(self.panel1)
            plotter.SetInitialSize(size=(800, 600))

        # enable the zoom feature (drag a box around area of interest)
        plotter.SetEnableZoom(True)


        # list of (x,y) data point tuples
        # data = [(1,2), (2,3), (3,5), (4,6), (5,8), (6,8), (12,10), (13,4)]

        # draw points as a line
        line = plot.PolyLine(data, colour='red', width=1)
        origLine = plot.PolyLine(origData, colour='blue', width=1)  
        # also draw markers, default colour is black and size is 2
        # other shapes 'circle', 'cross', 'square', 'dot', 'plus'
        marker = plot.PolyMarker(origData, marker='cross')
        yieldLine = plot.PolyLine(yieldCurve, colour='green', width=1)
        # set up text, axis and draw
        gc = plot.PlotGraphics([line, origLine, marker, yieldLine], 'Forward Rates Curve', 'Time (years)', 'Forward Rate (%)')
        plotter.Draw(gc, xAxis=(0,20), yAxis=(0,20))

        self.frame1.Show(True)
예제 #2
0
    def __init__(self):

        self.frame1 = wx.Frame(None,
                               title="wx.lib.plot",
                               id=-1,
                               size=(410, 340))
        self.panel1 = wx.Panel(self.frame1)
        self.panel1.SetBackgroundColour("yellow")
        if wx.VERSION[1] < 7:
            plotter = plot.PlotCanvas(self.panel1, size=(400, 300))
        else:
            plotter = plot.PlotCanvas(self.panel1)
            plotter.SetInitialSize(size=(400, 300))
        plotter.SetEnableZoom(True)
        data = [(1, 2), (2, 3), (3, 5), (4, 6), (5, 8), (6, 8), (12, 10),
                (13, 4)]
        # draw points as a line
        line = plot.PolyLine(data, colour='red', width=1)

        # also draw markers, default colour is black and size is 2

        # other shapes 'circle', 'cross', 'square', 'dot', 'plus'
        marker = plot.PolyMarker(data, marker='triangle')

        # set up text, axis and draw
        gc = plot.PlotGraphics([line, marker], 'Line/Marker Graph', 'x axis',
                               'y axis')
        plotter.Draw(gc, xAxis=(0, 15), yAxis=(0, 15))

        self.frame1.Show(True)
예제 #3
0
 def draw(self):
     # plot.
     self.canvas = plot.PlotCanvas(self, pos=(0,0), size=(940,720))
     self.canvas.EnableZoom = True
     self.canvas.SetBackgroundColour(self.bgColour)
     self.canvas.FontSizeLegend = 10
     self.canvas.SetForegroundColour(self.fgColour)
     self.lines = []
     self.title = self.name if self.name is not "" else "& ".join([x.lstrip(' ') for x in self.legends])
     for i in range(len(self.data)):
         for j in range(len(self.data[i])):
             line = plot.PolyLine(self.data[i][j], colour=self.colour[i].lower(), width=self.width, legend=(self.legends[i] if j == 0 and len(self.legends) > i else "^"))
             self.lines.append(line)
     # get client usable size of frame
     # needed for SaveFile() later
     self.frame_size = self.GetClientSize()
     self.canvas.SetInitialSize(size=self.frame_size)
     gc = plot.PlotGraphics(self.lines, self.title, self.xaxis, self.yaxis)
     self.canvas.Draw(gc, xAxis=self.x, yAxis=self.y)
     self.canvas.EnableZoom = False
     self.canvas.EnableAntiAliasing = True
     self.canvas.EnableHiRes = UIConstants.gHiRes
     if len(self.data) > 0:
         self.canvas.EnableLegend = UIConstants.gLegend
     self.canvas.EnableGrid = UIConstants.gGrid
예제 #4
0
    def OnTraffic(self, event):

        source = self.srctxt.GetValue()
        obj = graphs.Plot()

        gpcount, fncount, pcount, apcount = obj.get_traffic_data(
            self.list, source)
        frm = wx.Frame(self, -1, 'Look@MLKademlia', size=(600, 450))
        client = plot.PlotCanvas(frm)
        bar1 = plot.PolyLine([(1, 0), (1, gpcount)],
                             legend=u"get_peers",
                             colour='green',
                             width=25)
        bar2 = plot.PolyLine([(3, 0), (3, fncount)],
                             legend="find_node",
                             colour='blue',
                             width=25)
        bar3 = plot.PolyLine([(5, 0), (5, pcount)],
                             legend="Ping",
                             colour='yellow',
                             width=25)
        bar4 = plot.PolyLine([(6, 0), (6, apcount)],
                             legend="announce_peer",
                             colour='orange',
                             width=25)
        gc = plot.PlotGraphics([bar1, bar2, bar3, bar4],
                               'Total traffic Generated', 'Messages Type',
                               'No. of Messages')
        client.SetEnableLegend(True)
        client.Draw(gc, xAxis=(0, 10), yAxis=(0, len(self.list)))
        frm.Show(True)
예제 #5
0
    def OnConvergence(self, event):
        m1 = 0
        m2 = 0
        newdata = []
        #self.get_rtt_data()
        source = self.srctxt.GetValue()
        infoh = self.infotxt.GetValue()
        obj = graphs.Plot()
        newdata = obj.convergence(self.list, source, infoh)
        firstitem = []
        for item in newdata:
            firstitem.append(item[0])

        if firstitem:
            maxi = max(firstitem)
            mini = min(firstitem)
        frm = wx.Frame(self, -1, 'Look@MLKademlia', size=(600, 450))
        client = plot.PlotCanvas(frm)
        client.SetEnableZoom(True)
        line = plot.PolyLine(newdata, legend='', colour='red', width=1)
        marker = plot.PolyMarker(newdata,
                                 marker='triangle',
                                 colour='blue',
                                 size=1,
                                 width=1)
        gc = plot.PlotGraphics([line, marker], 'Lookup Convergence', 'Time(s)',
                               'Log Distance from Infohash')
        client.Draw(gc, xAxis=(mini - 1, maxi + 1), yAxis=(100, 180))
        #client.Draw(gc)
        frm.Show(True)
예제 #6
0
    def __init__(self, parent, id, title="plot", pos=wx.DefaultPosition):
        self.gui = parent
        self.toglX = 0
        self.toglY = 0
        wx.Frame.__init__(self,
                          parent,
                          id,
                          title,
                          pos=wx.DefaultPosition,
                          size=(350, 450))
        self.SetBackgroundColour('#EDFAFF')
        self.CenterOnScreen()
        hautSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.butAxes = wx.Button(self, self.ID_AXES, label="Axes")
        self.butExport = wx.Button(self, self.ID_EXPORT, label="Export")
        self.cnv = plot.PlotCanvas(self)
        self.cnv.SetInitialSize(size=(300, 400))
        hautSizer.AddMany([(self.butAxes, 0), (self.butExport, 0)])
        plotSizer = wx.BoxSizer(wx.VERTICAL)
        plotSizer.AddMany([(hautSizer, 0), (self.cnv, 0, wx.EXPAND)])
        #plotSizer.SetSizeHints(self)
        self.SetSizer(plotSizer)

        wx.EVT_BUTTON(self, self.ID_AXES, self.OnAxes)
        wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)
        wx.EVT_BUTTON(self, self.ID_EXPORT, self.OnExport)
예제 #7
0
	def updateTimePlot(self):
		
		#display
		dc = wx.WindowDC(self)
		#pen = wx.Pen("blue", width = 10, style = wx.SOLID)
		#dc.SetPen(pen)	
		dc.Clear()
		#dc.DrawRectangle(0,0, self.dimx,self.dimy)
		
		subpanel = wx.Panel(self,pos = ((self.dimx-self.imgx)/2, 0), size = (self.imgx,self.imgy) )
		
		sizer = wx.BoxSizer(wx.VERTICAL)
		canvas = plot.PlotCanvas(subpanel)
		canvas.SetFontSizeTitle(point=10)	
		canvas.SetFontSizeAxis(point=10)	
		sizer.Add(canvas, 1, wx.EXPAND, 0)
		subpanel.SetSizer(sizer) 
		subpanel.Layout()
		
		plotData = zip(self.xData,self.yData)
		
		line = plot.PolyLine(plotData, colour='red', width=1)
		
		if self.camera != None :
			title = "Temperature: "+str(self.camera.getTemperature())+" C"
		else :
			title = ""
		
		gc = plot.PlotGraphics([line], title, xLabel='Time (s)',yLabel='Average Power(uW)')
		canvas.Draw(gc, self.timeRange, self.currentRange)

		self.Show()				
예제 #8
0
 def OnScatter(self, event):
     frm = wx.Frame(self, -1, 'scatter', size=(600,450))
     client = plot.PlotCanvas(frm)
     markers = plot.PolyMarker(self.data, legend='', colour='pink', marker='triangle_down', size=1)
     gc = plot.PlotGraphics([markers], 'Scatter Graph', 'X Axis', 'Y Axis')
     client.Draw(gc, xAxis=(0,15), yAxis=(0,15))
     frm.Show(True)
예제 #9
0
 def OnLine(self, event):
     frm = wx.Frame(self, -1, 'line', size=(600,450))
     client = plot.PlotCanvas(frm)
     line = plot.PolyLine(self.data, legend='', colour='pink', width=5, style=wx.DOT)
     gc = plot.PlotGraphics([line], 'Line Graph', 'X Axis', 'Y Axis')
     client.Draw(gc,  xAxis= (0,15), yAxis= (0,15))
     frm.Show(True)
예제 #10
0
파일: Plots.py 프로젝트: manu080797/icesym
    def plotData(self, data, title='', x_axis='X Axis', y_axis='Y Axis'):
        # set up the plotting canvas
        plot_canvas = plot.PlotCanvas(self)
        # get client usable size of frame
        frame_size = self.GetClientSize()
        # needed for SaveFile() later
        plot_canvas.SetInitialSize(size=frame_size)
        # optionally allow scrolling
        plot_canvas.SetShowScrollbars(True)
        # optionally allow drag/draw rubberband area to zoom
        # use doubleclick to return to original
        # use right click to shrink
        plot_canvas.SetEnableZoom(True)
        # set the tick and axis label font size (default is 10 point)
        plot_canvas.SetFontSizeAxis(point=8)
        # set title font size (default is 15 point)
        plot_canvas.SetFontSizeTitle(point=10)

        # connect (x, y) points in data list with a line
        # also set color and width of line
        data_line = plot.PolyLine(data, colour='blue', width=1)

        # assign lines, title and axis labels
        gc = plot.PlotGraphics([data_line], title, x_axis, y_axis)
        # set x and y axis ranges and then draw the plot
        plot_canvas.Draw(gc)
예제 #11
0
 def __init__(self, parent):
     # parent is main frame
     self.parent = parent
     # Get the window positioning correctly
     pos = self.parent.GetPosition()
     pos = (pos[0]+100, pos[1]+100)
     wx.Frame.__init__(self, parent=self.parent, title="Trace view",
                       pos=pos, style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT)
     # MYID
     # This ID is given by the parent for an instance of this class
     self.MyID = None
     # Page
     self.Page = self.parent.notebook.GetCurrentPage()
     # Canvas
     self.canvas = plot.PlotCanvas(self)
     self.canvas.enableZoom = True
     if self.parent.notebook.GetPageCount() == 0:
         # We do not need to disable anything here.  user input.
         pass
     else:
         self.OnDraw()
     initial_size = (780, 250)
     self.SetSize(initial_size)
     self.SetMinSize(initial_size)
     # Icon
     if parent.MainIcon is not None:
         wx.Frame.SetIcon(self, parent.MainIcon)
     self.Show(True)
예제 #12
0
    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)
예제 #13
0
    def __init__(self, title):
        wx.Frame.__init__(self, None, wx.ID_ANY, title=title, size=(800,600))
        panel = wx.Panel(self, wx.ID_ANY)
        self.panel = panel

        topSizer = wx.BoxSizer(wx.VERTICAL)
        panel.SetSizer(topSizer)

        canvas = [ wxplot.PlotCanvas(panel, size=(800, 100)) for i in range(0,4) ]
        self.canvas = canvas

        y_datas = [ [] for i in range(0,4) ]
        self.y_datas = y_datas

        for idx in range(0,4):
            sizer = wx.BoxSizer(wx.HORIZONTAL)
            m_text = wx.StaticText(panel, wx.ID_ANY, "ap%d"%idx)
            sizer.Add(m_text, 0, wx.ALL, 5)
            sizer.Add(canvas[idx], 0, wx.ALL | wx.EXPAND)
            topSizer.Add(sizer, wx.CENTER)

#        topSizer.Fit(self)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(1000)
예제 #14
0
    def __init__(self):
        self.frame1 = wx.Frame(None, title="sz50股票波动率", id=-1, size=(500, 350))
        self.panel1 = wx.Panel(self.frame1)
        self.panel1.SetBackgroundColour("white")
        self.code = wx.TextCtrl(self.panel1, value="sz50", pos=(100, 220), size=(150, 20))
        wx.StaticText(self.panel1, -1, "标签代码:", pos=(30, 220), size=(60, 20))
        wx.StaticText(self.panel1, -1, "股票时间:", pos=(30, 260), size=(60, 20))
        self.startTime = wx.TextCtrl(self.panel1, value="2018-03-01", pos=(100, 260), size=(100, 20))
        self.endTime = wx.TextCtrl(self.panel1, value="2019-05-03", pos=(230, 260), size=(100, 20))
        Button1 = wx.Button(self.panel1, -1, "查找", (280, 215))
        Button1.Bind(wx.EVT_BUTTON, self.redraw)

        plotter = plot.PlotCanvas(self.panel1)
        plotter.SetInitialSize(size=(500, 200))
        code = self.code.GetValue()
        startTime = self.startTime.GetValue()
        endTime = self.endTime.GetValue()
        self.df = getDF(code, startTime, endTime)
        data = getData(self.df)
        line = plot.PolyLine(data, colour='red', width=1)

        gc = plot.PlotGraphics([line], 'sz50股票波动率', '时间', '波动率')
        plotter.Draw(gc)

        self.frame1.Show(True)
예제 #15
0
파일: demo.py 프로젝트: vvs31415/Phoenix
    def __init__(self, parent, wxid, title):
        wx.Frame.__init__(self, parent, wxid, title, wx.DefaultPosition,
                          (800, 600))

        # Now Create the menu bar and items
        self.mainmenu = wx.MenuBar()

        self._init_file_menu()
        self._init_plot_menu()
        self._init_options_menu()
        self._init_help_menu()

        self.SetMenuBar(self.mainmenu)

        # A status bar to tell people what's happening
        self.CreateStatusBar(1)

        self.client = wxplot.PlotCanvas(self)
        # define the function for drawing pointLabels
        #        self.client.SetPointLabelFunc(self.DrawPointLabel)
        self.client.pointLabelFunc = self.DrawPointLabel
        # Create mouse event for showing cursor coords in status bar
        self.client.canvas.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
        # Show closest point when enabled
        self.client.canvas.Bind(wx.EVT_MOTION, self.OnMotion)

        self.OnPlotDraw1(None)

        wx.CallAfter(
            wx.MessageBox,
            "Various plot types can be shown using the Plot menu. " +
            "Check out the Options menu too.", "wx.lib.plot Demo")
예제 #16
0
 def createPlotWnd(self):
     self.plotWnd = plot.PlotCanvas(self)
     self.plotWnd.SetEnableZoom(False)
     self.plotWnd.SetEnableGrid(True)
     self.plotWnd.SetEnableTitle(False)
     self.plotWnd.SetXSpec('min')
     self.plotWnd.SetFontSizeAxis(18)
     self.addLine([0, 1], [0, 0])
예제 #17
0
    def __init__(self, parent=None, id=-1, title=None):
        wx.Frame.__init__(self, parent, id, title)
        self.MainPanel = wx.Panel(self, size=(640, 640))
        self.MainPanel.SetBackgroundColour('WHITE')

        self.panel = wx.Panel(self.MainPanel, size=(640, 480))
        self.panel.SetBackgroundColour('WHITE')
        self.plotter = plot.PlotCanvas(self.MainPanel, size=(640, 640 - 480))
        self.plotter.SetEnableZoom(False)
        self.plotter.SetEnableLegend(True)
        self.plotter.SetFontSizeLegend(10.5)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.panel)
        mainSizer.Add(self.plotter)

        self.SetSizer(mainSizer)
        self.Fit()

        self.A = Agent(self.panel, 240, 49)
        self.B = Agent(self.panel, 240, 49)
        self.B.B_color = wx.Colour(112, 173, 71)

        # OutrBox
        self.Box = Walls(640, 479, 0, 479)
        self.Box.addPoint(0, 0)
        self.Box.addPoint(640, 0)
        self.Box.addPoint(640, 479)

        # Oval Course
        Rad = 190.0
        Poly = 16
        self.Course = Walls(240, 50, 640 - (50 + Rad), 50)
        for i in range(1, Poly):
            self.Course.addPoint(
                Rad * math.cos(-np.pi / 2.0 + np.pi * i / Poly) + 640 -
                (50 + Rad),
                Rad * math.sin(-np.pi / 2.0 + np.pi * i / Poly) + 50 + Rad)
        self.Course.addPoint(240, 50 + Rad * 2)
        for i in range(1, Poly):
            self.Course.addPoint(
                Rad * math.cos(np.pi / 2.0 + np.pi * i / Poly) + (50 + Rad),
                Rad * math.sin(np.pi / 2.0 + np.pi * i / Poly) + 50 + Rad)
        self.Course.addPoint(240, 50)

        self.Bind(wx.EVT_CLOSE, self.CloseWindow)

        self.cdc = wx.ClientDC(self.panel)
        w, h = self.panel.GetSize()
        self.bmp = wx.EmptyBitmap(w, h)

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.timer.Start(20)

        self.i = 0
        self.tmp_sum = 0.0
        self.data = []
예제 #18
0
    def __init__(self, parent, plottersize):
        """ create the figure and canvas to be redrawn and initialize plotting parameters"""
        self.parentPanel = parent
        self.plotpanel = wx.Panel(parent)
        self.plotpanel.SetBackgroundColour("white")

        self.xvalues = []
        self.yvalues = []
        self.ybuffer = []
        #count the number of ECG samples received
        self.ysamples_counter = 0

        if wx.VERSION[1] < 7:
            self.plotter = plot.PlotCanvas(self.plotpanel, size=plottersize)
        else:
            self.plotter = plot.PlotCanvas(self.plotpanel)
            self.plotter.SetInitialSize(size=plottersize)

        self.plotter.SetEnableZoom(True)
        #self.plotter.SetEnableGrid(True)

        self.plotter.SetXSpec(type='none')
        self.plotter.SetYSpec(type='none')

        self.xvalues = list()
        for i in range(0, ECG_LEN):
            self.xvalues.insert(len(self.xvalues), float(i) / ECG_FS)

        self.yvalues = list()
        for i in range(0, ECG_LEN):
            self.yvalues.insert(len(self.yvalues), 0)

        data = ()
        for i in range(0, ECG_LEN):
            a = (self.xvalues[i], self.yvalues[i]),
            data = data + a

        grided_data = self.setGrid()
        #add the data to the grid lines
        line = plot.PolyLine(data, colour='red', width=2)
        grided_data.append(line)

        #set up text, axis and draw
        self.gc = plot.PlotGraphics(grided_data)
        self.plotter.Draw(self.gc, xAxis=(0, 3.02), yAxis=(-1.52, 1.5))
예제 #19
0
 def OnBar(self, event):
     frm = wx.Frame(self, -1, 'bar', size=(600,450))
     client = plot.PlotCanvas(frm)
     bar1 = plot.PolyLine([(1, 0), (1,5)], legend='', colour='gray', width=25)
     bar2 = plot.PolyLine([(3, 0), (3,8)], legend='', colour='gray', width=25)
     bar3 = plot.PolyLine([(5, 0), (5,12)], legend='', colour='gray', width=25)
     bar4 = plot.PolyLine([(6, 0), (6,2)], legend='', colour='gray', width=25)
     gc = plot.PlotGraphics([bar1, bar2, bar3, bar4],'Bar Graph', 'X Axis', 'Y Axis')
     client.Draw(gc, xAxis=(0,15), yAxis=(0,15))
     frm.Show(True)
예제 #20
0
    def __init__(self,
                 parent=None,
                 id=-1,
                 title='DES Quick Look',
                 size=(1000, 1000)):
        # inherit super class
        super().__init__(parent, id, title, size)
        #super().__init__(parent=None, id=-1, title='DES Quick Look',size=(500,500))

        self.SetBackgroundColour('Dark Grey')
        #self.Maximize(True)

        #
        # Parts on frmMain
        #
        # panel
        pnlMain = wx.Panel(self, -1)
        #pnlMain = wx.Panel(self,id=wx.ID_ANY,pos=wx.DefaultPosition,size=wx.DefaultSize)

        #
        # Parts on pnlMain?
        #
        # plotter initialize
        self.plotter = plt.PlotCanvas(self, wx.ID_ANY)
        # - content
        line = plt.PolyLine(xy1_val)
        gc = plt.PlotGraphics([line])
        self.plotter.Draw(gc)
        # - position and size
        sizer = wx.GridSizer(1, 1, gap=(0, 0))
        sizer.Add(self.plotter, flag=wx.EXPAND)
        self.SetSizer(sizer)
        # - initialize
        self.xx_val = 0.0
        self.plot_data = [[0.0, 0.0]]
        self.plotter.xSpec = (0, 100)

        #
        # Events generated in frmMain
        #
        self.Bind(wx.EVT_CLOSE, self.OnClose)

        self.tmrRefreshPlotter = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnRefreshPlotter, self.tmrRefreshPlotter)
        self.tmrRefreshPlotter.Start(REFLESH_RATE_PLOTTER)

        self.tmrRefreshDigitalIndicator = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnRefreshDigitalIndicator,
                  self.tmrRefreshDigitalIndicator)
        self.tmrRefreshDigitalIndicator.Start(REFLESH_RATE_DIGITAL_INDICATOR)

        #
        # switch frmMain to visible state after prepalation
        #
        self.Show()
예제 #21
0
  def __init__(self, parent,elem):
    XmlPanel.__init__(self, parent)
    self.elem = elem
    self.plot = plot.PlotCanvas(self)
    self.sizer = wx.BoxSizer(wx.VERTICAL)
    self.legendSize = 200
    
    psize = self.parent.GetSize()
    self.setSize(psize.x-30,psize.y/2)  # Start with the biggest possible size

    self.render()
예제 #22
0
파일: wxplot.py 프로젝트: peicer/wistool
 def __init__(self, parent, csize=(200, 2000)):
     wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY, size=csize)
     self.scroll = wx.ScrolledWindow(self, -1)
     self.scroll.SetScrollbars(2, 2, csize[0] / 2, csize[1] / 2)
     self.panel = wxplot.PlotCanvas(self.scroll, size=csize)
     # Edit panel-wide settings
     axes_pen = wx.Pen(wx.BLUE, 1)
     self.panel.axesPen = axes_pen
     self.panel.enableAxes = (True, True, True, True)
     self.panel.enableAxesValues = (True, True, True, False)
     self.panel.enableTicks = (True, True, True, False)
예제 #23
0
    def __init__(self, *args, **kwgs):

        wx.Panel.__init__(self, *args, **kwgs)

        # canvas object
        self.canvas = wxplot.PlotCanvas(self)
        # toolbar id
        self.tidHome = wx.NewId()
        self.tidDrag = wx.NewId()
        self.tidZoom = wx.NewId()
        self.tidSave = wx.NewId()
        # toolbar
        self.toolbar = wx.ToolBar(self)
        # size
        self.toolbar.SetToolBitmapSize((24, 24))
        # toolbar buttons
        self.toolbar.AddTool(self.tidHome,
                             '',
                             peiHome.GetBitmap(),
                             shortHelp='Home')
        self.toolbar.AddCheckTool(self.tidDrag,
                                  '',
                                  peiMove.GetBitmap(),
                                  shortHelp='Pan')
        self.toolbar.AddCheckTool(self.tidZoom,
                                  '',
                                  peiZoom.GetBitmap(),
                                  shortHelp='Zoom')
        self.toolbar.AddTool(self.tidSave,
                             '',
                             peiSave.GetBitmap(),
                             shortHelp='Save')
        '''
        self.toolbar.AddTool(self.tidHome, '', wx.Bitmap('home.png'),
                shortHelp = 'Home')
        self.toolbar.AddCheckTool(self.tidDrag, '', wx.Bitmap('move.png'),
                shortHelp = 'Pan')
        self.toolbar.AddCheckTool(self.tidZoom, '', wx.Bitmap('zoom.png'),
                shortHelp = 'Zoom')
        self.toolbar.AddTool(self.tidSave, '', wx.Bitmap('save.png'),
                shortHelp = 'Save')
        '''
        self.toolbar.Realize()

        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=self.tidHome)
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=self.tidDrag)
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=self.tidZoom)
        self.Bind(wx.EVT_TOOL, self.OnToolClick, id=self.tidSave)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND)
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.SetSizer(self.sizer)
        self.Fit()
예제 #24
0
 def __init__(self):
     wx.MDIChildFrame.__init__(self,None, -1, "Child Window")
     menu = wx.Menu()
     menu.Append(5000, "&New Window")
     menu.Append(5001, "&Exit")
     menubar = wx.MenuBar()
     menubar.Append(menu, "&File")
     self.SetMenuBar(menubar)
     self.Bind(wx.EVT_MENU, self.draw, id=5000)
     self.Bind(wx.EVT_MENU, self.closeframe, id=5001)
     self.pc = wxPyPlot.PlotCanvas(self)
예제 #25
0
 def MakeSBFLResultGraph(self, panel, group):
     xy_val = []
     for member in group[0]:
         xy_val.append((member["Number"], member["Suspicious"]))
     graph = plot.PlotCanvas(panel, wx.ID_ANY, wx.DefaultPosition,
                             wx.DefaultSize, wx.HSCROLL | wx.VSCROLL)
     line = plot.PolyLine(xy_val)
     graphic = plot.PlotGraphics([line], group[0][0]["Sourcefile"],
                                 "Line No.", "Suspicious value")
     graph.ySpec = (0, 1)
     graph.Draw(graphic)
     return graph
예제 #26
0
    def configure_plotter(self):
        ### initialize
        # - data set
        self.x_series = []
        self.y_series = []
        # print("GUI PLT: x_series = {}".format(self.x_series))
        # print("GUI PLT: y_series = {}".format(self.y_series))

        # - plotter
        self.plotter = plot.PlotCanvas(self, wx.ID_ANY)
        # self.plotter = plt.PlotCanvas(self, wx.ID_ANY, size=(400, 400))
        # self.plotter.SetEnableZoom(True)

        # return None     # for debug

        ### configure
        i = 0

        # - data set
        # line = plot.PolyLine([(0.0, 0.0)])
        line = plot.PolyLine(list(zip(self.x_series, self.y_series)))
        self.graphic = plot.PlotGraphics([line])
        # self.graphic = plot.PlotGraphics([line], 'title', 'UTC time, s', self.PlotterAttr[i]['y_label'])
        # self.graphic = plot.PlotGraphics([line], xLabel='UTC time, s', yLabel=self.PlotterAttr[i]['y_label'])

        self.graphic.xLabel = 'UTC time, s'
        self.graphic.yLabel = self.PlotterAttr[i]['y_label']

        # - axes
        t_min = 0.0

        self.plotter.ForegroundColour('BLACK')
        self.plotter.xSpec = (t_min, t_min + self.__T_RANGE)
        self.plotter.ySpec = (self.PlotterAttr[i]['y_min'],
                              self.PlotterAttr[i]['y_max'])
        # self.plotter.enableXAxisLabel = True
        # self.plotter.enableYAxisLabel = True

        print(f'GUI PLT: graphic.xLabel = {self.graphic.xLabel}')
        print(
            f'GUI PLT: plotter.enableXAxisLabel = {self.plotter.enableXAxisLabel}'
        )

        # - draw tentatively
        self.plotter.Draw(self.graphic)
        # self.plotter.Draw(self.graphic, xAxis=(0.0, 30.0), yAxis=(0.0, 4.0))

        sizer = wx.GridSizer(1, 1, gap=(0, 0))
        sizer.Add(self.plotter, proportion=1, flag=wx.EXPAND)
        # sizer = wx.BoxSizer(wx.VERTICAL)
        # sizer.Add(self.plotter)

        self.SetSizer(sizer)
예제 #27
0
 def redraw(self, event):
     plotter = plot.PlotCanvas(self.panel1)
     plotter.SetInitialSize(size=(500, 200))
     code = self.code.GetValue()
     startTime = self.startTime.GetValue()
     endTime = self.endTime.GetValue()
     self.df = getDF(code, startTime, endTime)
     for i in range(len(self.df)):
         data2 = getData(self.df[:i])
         line = plot.PolyLine(data2, colour='red', width=1)
         gc = plot.PlotGraphics([line], code + '股票波动率', '时间', '波动率')
         plotter.Draw(gc)
예제 #28
0
    def __init__(self, parent=None, id=-1, title=None):
        wx.Frame.__init__(self, parent, id, title)
        self.MainPanel = wx.Panel(self, size=(640, 640))
        self.MainPanel.SetBackgroundColour('WHITE')
        
        self.panel = wx.Panel(self.MainPanel, size = (640,480))
        self.panel.SetBackgroundColour('WHITE')
        self.plotter = plot.PlotCanvas(self.MainPanel, size =(640, 640-480))
        self.plotter.SetEnableZoom(False)
        self.plotter.SetEnableLegend(True)
        self.plotter.SetFontSizeLegend(10.5)
        
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.panel)
        mainSizer.Add(self.plotter)

        self.SetSizer(mainSizer)
        self.Fit()
 
        self.A = Agent(self.panel, 150, 100 )
        self.B = Agent(self.panel, 400, 300, model = self.A.model)
        self.C = Agent(self.panel, 400, 150, model = self.A.model)
        self.D = Agent(self.panel, 320, 240, model = self.A.model)
        
        self.greenB = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), 
                        wx.Colour(112,173,71), property =  1) for i in range(0, 15)]
        self.redB  = [Ball(rnd.randint(40, 600),rnd.randint(40, 440), 
                        wx.Colour(237,125,49), property = 2) for i in range(0, 10)]
         
        # OutrBox
        self.Box = Walls(640, 480, 0, 480)
        self.Box.addPoint(0,0)
        self.Box.addPoint(640,0)
        self.Box.addPoint(640,480)
        
        # Wall in the world
        self.WallA = Walls(96, 90, 256, 90)
        self.WallA.addPoint(256, 390)
        self.WallA.addPoint(96,390)
        
        self.Bind(wx.EVT_CLOSE, self.CloseWindow)
 
        self.cdc = wx.ClientDC(self.panel)
        w, h = self.panel.GetSize()
        self.bmp = wx.EmptyBitmap(w,h)
 
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer)
        self.timer.Start(20)
        
        self.i = 0
        self.tmp_sum = 0.0
        self.data = []
예제 #29
0
 def __init__(self, *args, **kw):
     super(Plot_Pnl, self).__init__(*args, **kw)
     self.my_cas = plot.PlotCanvas(self)
     vb = wx.BoxSizer(wx.VERTICAL)
     hb = wx.BoxSizer(wx.HORIZONTAL)
     line = plot.PolyLine([])
     self.gc = plot.PlotGraphics([line], u"测试波形图", "x", "y")
     self.my_cas.Draw(self.gc)
     vb.AddMany([
         (hb, 0, wx.EXPAND | wx.ALL, 5),
         (self.my_cas, 1, wx.EXPAND | wx.ALL, 0),
     ])
     self.SetSizer(vb)
예제 #30
0
 def CreatePlotCanvases(self):
     """Create plot canvases according to the number of bands"""
     for band in self.bandList:
         canvas = plot.PlotCanvas(self.canvasPanel)
         canvas.SetMinSize((-1, 140))
         canvas.SetFontSizeTitle(10)
         canvas.SetFontSizeAxis(8)
         self.canvasList.append(canvas)
         
         self.canvasSizer.Add(item = canvas, proportion = 1, flag = wx.EXPAND, border = 0)
     
     self.SetVirtualSize(self.GetBestVirtualSize())
     self.Layout()