def OnPlotBar(self, event=None): data = self.data ## sans fusion if isinstance( data, list): line = [plot.PolyLine([(c[0], 0), (c[0],c[1])], legend='', colour='gray', width=25) for c in data] self.gc = plot.PlotGraphics(line, self.title, self.xLabel, self.yLabel) xMin,xMax,yMin,yMax = get_limit(data) ##avec fusion (voir attribut _fusion de QuickScope) else: L=[] xMin, xMax = 0,0 yMin, yMax = 0,0 for k in data: d = data[k] for c in d: L.append(plot.PolyLine([(c[0], 0), (c[0],c[1])], legend='', colour='gray', width=25)) a,b,c,d = get_limit(d) if a < xMin: xMin=a if b > xMax: xMax= b if c < yMin: yMin=c if d > yMax:yMax=d self.gc = plot.PlotGraphics(L, self.title, self.xLabel, self.yLabel) self.client.Draw(self.gc, xAxis = (float(xMin),float(xMax)), yAxis = (float(yMin),float(yMax)))
def test_draw(self, draw1): data = [[1, 10], [2, 5], [3, 10], [4, 5]] line = plot.PolyLine(data, colour="red", width=1) data2 = [[1, 12], [2, 9], [3, 20], [4, 5]] line2 = plot.PolyLine(data2, colour="green", width=1) gc = plot.PlotGraphics([line, line2], "test", "x", "y") return gc
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)
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)
def UpdateGraph(self): if self.data is None: return wfm = self.choWave.GetStringSelection() frq = float(self.choFreq.GetStringSelection()) # time domain plot if 'Chirp' in wfm: # display first 500msec only dlen = int(SamplingFreq / 2) else: # display first 20 cycles only dlen = int(15 * SamplingFreq / frq) line1 = wxplot.PolyLine(list(zip(self.x[:dlen], self.data[:dlen])), colour='red') graph1 = wxplot.PlotGraphics([line1]) # frequency domain plot N = self.data.size Y = np.fft.rfft(self.data) / N F = np.fft.rfftfreq(N, 1 / SamplingFreq) line2 = wxplot.PolyLine(list(zip(F, np.abs(Y)))) graph2 = wxplot.PlotGraphics([line2]) self.spw.DrawGraphics(graph1, graph2)
def new_data(self, s, name): if ',' in name: names = name.split(',') title = "" line = [] for n in names: data = zip(range(0, len(s.boot[n + "_history"])), s.boot[n + "_history"]) colours = ["red", "blue", "black", "brown", "pink"] line.append( plot.PolyLine(data, colour=colours[names.index(n)], width=1)) title += n.capitalize() + ": " + colours[names.index(n)] + " " l = len(s.boot[n + "_history"]) gc = plot.PlotGraphics(line, title) self.Draw(gc, xAxis=(0, l), yAxis=(self.min, self.max)) else: data = zip(range(0, len(s.boot[name + "_history"])), s.boot[name + "_history"]) line = plot.PolyLine(data, colour='red', width=1) gc = plot.PlotGraphics([line], name.capitalize()) self.Draw(gc, xAxis=(0, len(s.boot[name + "_history"])), yAxis=(self.min, self.max))
def OnPlotSquare(self, event=None): data = self.data ## sans fusion if isinstance( data, list): ### formatage des données spécifique au square data = [] for v1,v2 in zip(self.data,[(self.data[i+1][0], self.data[i][1]) for i in xrange(len(self.data)-1)]): data.append(v1) data.append(v2) if self.normalize: m = max(map(lambda a: a[1], data)) data = map(lambda b: (b[0], b[1]/m), data) line = plot.PolyLine(data, legend = 'Port 0 %s'%self.legend, colour = 'black', width = 1) self.gc = plot.PlotGraphics([line], self.title, self.xLabel, self.yLabel) ### gestion automatique des bornes xMin,xMax,yMin,yMax = get_limit(data) ##avec fusion (voir attribut 'fusion' de QuickScope) else: L = [] xMin, xMax, yMin, yMax = 0,0,0,0 data_list = data.values() for ind,d in enumerate(data_list): ### formatage des données spécifique au square dd = [] for v1,v2 in zip(d,[ (d[i+1][0], d[i][1]) for i in xrange(len(d)-1)]): dd.append(v1) dd.append(v2) ### gestion des couleures try: c = LColour[ind] except IndexError: c = LColour[0] if self.normalize: m = max(map(lambda a: a[1], dd)) dd = map(lambda b: (b[0], b[1]/m), dd) L.append(plot.PolyLine(dd, legend = 'Port %d %s'%(ind,self.legend), colour = c, width=1)) ### gestion automatique des bornes a,b,c,d = get_limit(dd) if a < xMin: xMin=a if b > xMax: xMax=b if c < yMin: yMin=c if d > yMax:yMax=d self.gc = plot.PlotGraphics(L, self.title, self.xLabel, self.yLabel) self.client.Draw(self.gc, xAxis = (float(xMin),float(xMax)), yAxis = (float(yMin),float(yMax)))
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)
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")
def PlotTrace(self, traceA, traceB): '''Plot ADC waveforms''' plts = [] if traceA: plts.append(plot.PolyLine(traceA, colour='blue', width=1)) if traceB: plts.append(plot.PolyLine(traceB, colour='red', width=1)) self.plot.SetUseScientificNotation(False) gc = plot.PlotGraphics(plts, 'ADC Waveform Data', 'uS', 'ADC') self.plot.Draw(gc) self.Show(True)
def OnPlotBar(self,event): #if self.timer.IsRunning(): ### unbinding paint event if self.type != "PlotBar": self.type = "PlotBar" self.Unbind(wx.EVT_PAINT) self.Bind(wx.EVT_PAINT, getattr(self, "On%s"%self.type)) ## sans fusion if self.iport is not None: data = self.atomicModel.results[self.iport] line = [plot.PolyLine([(c[0], 0), (c[0],c[1])], legend='', colour='gray', width=25) for c in data] self.gc = plot.PlotGraphics(line, self.title, self.xLabel, self.yLabel) xMin,xMax,yMin,yMax = get_limit(data) ##avec fusion (voir attribut _fusion de QuickScope) else: data = self.atomicModel.results L=[] xMin, xMax, yMin, yMax = 0,0,0,0 data_list = data.values() for ind,d in enumerate(data_list): #ind = data_list.index(d) try: c = LColour[ind] except IndexError: c = LColour[0] for c in d: L.append(plot.PolyLine([(c[0], 0), (c[0],c[1])], legend='', colour='gray', width=25)) a,b,c,d = get_limit(d) if a < xMin: xMin = a if b > xMax: xMax = b if c < yMin: yMin = c if d > yMax: yMax = d self.gc = plot.PlotGraphics(L, self.title, self.xLabel, self.yLabel) try: self.client.Draw(self.gc, xAxis = (float(xMin),float(xMax)), yAxis = (float(yMin),float(yMax))) except Exception: sys.stdout.write(_("Error trying to plot")) if self.sim_thread is None or not self.sim_thread.isAlive(): self.timer.Stop()
def draw(self,x,arry,legd,title,Xtitle,Ytitle,typ='-',axes=None): x,arry=transpose(array(x,ndmin=2)),array(arry) # x en vertical self.x, self.arry, self.legd, self.title = x, arry, legd, title self.Xtitle,self.Ytitle,self.typ = Xtitle, Ytitle,typ self.xlog, self.ylog = False, False self.lignes = [];cols=['red','blue','green','orange','cyan','black']*5 # verifier dimensions des vecteurs entree if len(shape(x))==1: x1 = ones((len(x),1))+0.; if len(shape(arry))==1: arry1 = ones((len(arry),1))+0.; arry1[:,0]=arry; arry=arry1*1.;ny=1 else : [nt,ny] = shape(arry) if axes!=None: a,b,self.xlog,c,d,self.ylog = axes x2 = x*1.; arry2 = arry*1.; if self.xlog: x2[x2<=0.]=1e-7;x2 = log10(x) if self.ylog: arry2[arry2<=0.]=1e-7;arry2 = log10(arry) # creer les lignes if ny==1: dataL = concatenate([x2,arry2],axis=1) if typ=='-': gobj = plot.PolyLine(dataL,colour='red') else : gobj = plot.PolyMarker(dataL,colour='red') self.lignes.append(gobj) else : #print 'mydlg',ny,cols,legd for i in range(ny): dataL = concatenate([x2,arry2[:,i:i+1]],axis=1) if typ=='-': gobj = plot.PolyLine(dataL,colour=cols[i],legend=legd[i]) else : gobj = plot.PolyMarker(dataL,colour=cols[i],legend=legd[i]) self.lignes.append(gobj) drawObj = plot.PlotGraphics(self.lignes,title,Xtitle,Ytitle) # limite des axes if axes==None or self.xlog: xmn = amin(amin(x2)); xmx = amax(amax(x2)); dmx = xmx-xmn; self.xmx=xmx+dmx/20.; self.xmn=xmn-dmx/20. else : self.xmn,self.xmx,a,b,c,d = axes if axes==None: # or self.ylog: ymn = amin(amin(arry2));ymx = amax(amax(arry2));#print 'dlg',ymn,ymx dmy = ymx-ymn; self.ymx=ymx+dmy/20.; self.ymn=ymn-dmy/20. else : a,b,c,self.ymn,self.ymx,d = axes if self.ymn==self.ymx: #print arry self.ymn=self.ymn*.99;self.ymx=self.ymx*1.01 #self.ymn = max(self.ymn,0.);self.xmn = max(self.xmn,0.) self.cnv.SetEnableLegend(True);self.cnv.SetEnableGrid(True) self.cnv.Draw(drawObj,xAxis=(float(self.xmn),float(self.xmx)), yAxis=(float(self.ymn),float(self.ymx)))
def OnPlotLine(self, event=None): data = self.data ## sans fusion if isinstance(data, list): if self.normalize: m = max(map(lambda a: a[1], data)) data = map(lambda b: (b[0], b[1] / m), data) line = plot.PolyLine(data, legend='Port 0 %s' % self.legend, colour='black', width=1) self.gc = plot.PlotGraphics([line], self.title, self.xLabel, self.yLabel) xMin, xMax, yMin, yMax = get_limit(data) ##avec fusion (voir attribut _fusion de QuickScope) else: L = [] xMin, xMax, yMin, yMax = 0, 0, 0, 0 data_list = data.values() for ind, d in enumerate(data_list): try: c = LColour[ind] except IndexError: c = LColour[0] if self.normalize: m = max(map(lambda a: a[1], d)) d = map(lambda b: (b[0], b[1] / m), d) L.append( plot.PolyLine(d, legend='Port %d %s' % (ind, self.legend), colour=c, width=1)) a, b, c, d = get_limit(d) if a < xMin: xMin = a if b > xMax: xMax = b if c < yMin: yMin = c if d > yMax: yMax = d self.gc = plot.PlotGraphics(L, self.title, self.xLabel, self.yLabel) self.client.Draw(self.gc, xAxis=(float(xMin), float(xMax)), yAxis=(float(yMin), float(yMax)))
def _draw7Objects(): """Log10 on both axes""" x = np.arange(-1000, 1000, 1) y1 = 4.5 * x**2 y2 = 2.2 * x**3 points1 = np.transpose([x, y1]) points2 = np.transpose([x, y2]) line1 = wxplot.PolyLine(points1, legend='quadratic', colour='blue', width=1) line2 = wxplot.PolyLine(points2, legend='cubic', colour='red', width=1) return wxplot.PlotGraphics([line1, line2], "double log plot", "Value X", "Value Y")
def plot2(self, key, t_new, x_new, y_new): """NOT USED, DELETE EVENTUALLY """ self.plotSets[key][0] = np.append(self.plotSets[key][0][1:], t_new) self.plotSets[key][1] = np.append(self.plotSets[key][1][1:], x_new) self.plotSets[key][2] = np.append(self.plotSets[key][2][1:], y_new) line_x = wxplot.PolyLine(list( zip(self.plotSets[key][0], self.plotSets[key][1])), colour="red") line_y = wxplot.PolyLine(list( zip(self.plotSets[key][0], self.plotSets[key][2])), colour="green") return wxplot.PlotGraphics([line_x, line_y])
def OnDraw(self): traces = self.Page.corr.traces self.canvas.SetEnableLegend(True) if len(traces) == 1: self.trace = 1 * traces[0].trace # We want to have the trace in [s] here. self.trace[:, 0] = self.trace[:, 0] / 1000 line = plot.PolyLine(self.trace, legend='{:.2f}kHz'.format( traces[0].countrate), colour='blue', width=1) lines = [line] xmax = np.max(self.trace[:, 0]) xmin = np.min(self.trace[:, 0]) ymax = np.max(self.trace[:, 1]) ymin = np.min(self.trace[:, 1]) elif len(traces) == 2: # This means that we have two (CC) traces to plot self.tracea = 1 * traces[0].trace self.tracea[:, 0] = self.tracea[:, 0] / 1000 self.traceb = 1 * traces[1].trace self.traceb[:, 0] = self.traceb[:, 0] / 1000 linea = plot.PolyLine(self.tracea, legend='channel 1 {:.2f}kHz'.format( traces[0].countrate), colour='blue', width=1) lineb = plot.PolyLine(self.traceb, legend='channel 2 {:.2f}kHz'.format( traces[1].countrate), colour='red', width=1) lines = [linea, lineb] xmax = max(np.max(self.tracea[:, 0]), np.max(self.traceb[:, 0])) xmin = min(np.min(self.tracea[:, 0]), np.min(self.traceb[:, 0])) ymax = max(np.max(self.tracea[:, 1]), np.max(self.traceb[:, 1])) ymin = min(np.min(self.tracea[:, 1]), np.min(self.traceb[:, 1])) else: self.canvas.Clear() return # Plot lines self.canvas.Draw(plot.PlotGraphics(lines, xLabel='time [s]', yLabel='count rate [kHz]'), xAxis=(xmin, xmax), yAxis=(ymin, ymax))
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)
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)
def plot1(self, key, t_new, x_new): """Plots a line for one data point for a given time. Parameters ---------- key : str reference to the plot to plot on. t_new : float time point x_new : float data point Returns ------- PlotGraphics obj plot object with updated plot line """ self.plotSets[key][0] = np.append(self.plotSets[key][0][1:], t_new) self.plotSets[key][1] = np.append(self.plotSets[key][1][1:], x_new) line_x = wxplot.PolyLine(list( zip(self.plotSets[key][0], self.plotSets[key][1])), colour="red", width=5) return wxplot.PlotGraphics([line_x])
def CreateMinRange(self, bandValues): maxVal = max(bandValues.histo) rMin = bandValues.rangeMin points = [(rMin, 0), (rMin, maxVal)] return plot.PolyLine(points, colour=wx.RED, width=1)
def __init__(self, parent, id, size): ''' Initialization routine for the this panel.''' plot.PlotCanvas.__init__(self, parent, id, style=wx.BORDER_NONE, size=(1000, 700)) diff_raw = get_json_info("diffhist", diff_hist) diff_b = diff_raw[0] diff_d = diff_raw[1] max_d = max(diff_d) min_d = min(diff_d) d_inc = (max_d - min_d) / len(diff_b) d_min = min_d - (d_inc * 10) d_max = max_d + (d_inc * 10) b_min = diff_b[0] - 1 b_max = diff_b[-1] + 1 self.data = list(zip(diff_b, diff_d)) line = plot.PolyLine(self.data, legend='', colour='red', width=1) gc = plot.PlotGraphics([line], 'Difficulty History (last {} blocks)'.format( str(diff_hist)), 'Block Height', 'Difficulty') self.Draw(gc, xAxis=(b_min, b_max), yAxis=(d_min, d_max))
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()
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)
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)
def CreatePlotList(self): """Make list of elements to plot""" # graph the cell value, frequency pairs for the histogram self.plotlist = [] for r in self.rasterList: if len(self.raster[r]["datalist"]) > 0: col = wx.Colour( self.raster[r]["pcolor"][0], self.raster[r]["pcolor"][1], self.raster[r]["pcolor"][2], 255, ) self.raster[r]["pline"] = plot.PolyLine( self.raster[r]["datalist"], colour=col, width=self.raster[r]["pwidth"], style=self.linestyledict[self.raster[r]["pstyle"]], legend=self.raster[r]["plegend"], ) self.plotlist.append(self.raster[r]["pline"]) if len(self.plotlist) > 0: return self.plotlist else: return None
def PlotAccum(self, accum): '''Plot Correlation Integral''' plts = [plot.PolyLine(accum, colour='black', width=1)] self.plot.SetUseScientificNotation(True) gc = plot.PlotGraphics(plts, 'Correlation Integral', 'sec', 'integral') self.plot.Draw(gc) self.Show(True)
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)
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
def plot(self, esp): nper = float(self.Limit[0].GetValue()) tmax = float(self.Limit[1].GetValue()) Cmax = float(self.Limit[2].GetValue()) if esp >= 0: # dessin a partir de Cinj, evt num espece per = array(self.periods) conc = self.Cinj[:, esp] dt, Cmax = per[0], max(float(max(conc)), Cmax) if len(per) > 1: dt = per[1] - per[0] t2 = self.periods - dt / 2. else: # dessin a partir de modifier plot self.choix.SetSelection(0) self.Cinj = ones((nper, len(self.especes))) * 1. dt = tmax / nper t2 = arange(dt / 2., tmax, dt) + 0. self.periods = t2 + dt / 2. conc = t2 * 0. + Cmax / 2. # crer les lignes de l'histogramme self.lignes = [] for i in range(len(t2)): t3 = [ t2[i] - dt / 2., t2[i] - dt / 2., t2[i] + dt / 2., t2[i] + dt / 2. ] c3 = [0., conc[i], conc[i], 0.] dataL = transpose(array([t3, c3])) self.lignes.append(plot.PolyLine(dataL)) # creer les points self.data = transpose(array([t2, conc])) self.poly = plot.PolyMarker(self.data, marker='circle', colour='red') lli = self.lignes * 1 lli.append(self.poly) drawObj = plot.PlotGraphics(lli, "source", "temps", "concentration") self.cnv.Draw(drawObj, xAxis=(0, tmax), yAxis=(0, Cmax * 1.1)) self.Cmax = Cmax
def __init__(self, parent, id, size, data=zero_history): ''' Initialization routine for the this panel.''' plot.PlotCanvas.__init__(self, parent, id, size=size) self.data = data line = plot.PolyLine(self.data) gc = plot.PlotGraphics([line], xLabel="время", yLabel="%") self.Draw(gc, )