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 refreshPlot(self): if self.modeUVVIS: gc = plot.PlotGraphics(self.lines, '', 'Wavelength', 'OD') else: gc = plot.PlotGraphics(self.lines, '', 'Wavelength', 'Counts') self.plotWnd.Draw(gc)
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 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 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 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)
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 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 __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 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 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 _draw8Objects(): """ Box plot """ data1 = np.array([ np.NaN, 337, 607, 583, 512, 531, 558, 381, 621, 574, 538, 577, 679, 415, 454, 417, 635, 319, 350, 183, 863, 337, 607, 583, 512, 531, 558, 381, 621, 574, 538, 577, 679, 415, 454, 417, 635, 319, 350, 97 ]) data2 = np.array([ 912, 337, 607, 583, 512, 531, 558, 381, 621, 574, 538, 532, 829, 82, 454, 417, 635, 319, 350, 183, 863, 337, 607, 583, 512, 531, 558, 866, 621, 574, 538, 577, 679, 415, 326, 417, 635, 319, 350, 97 ]) data2 = data2 * 0.9 data1 = np.array([(0, x) for x in data1]) data2 = np.array([(1, x) for x in data2]) data3 = np.random.gamma(2, 2, 500) * 30 + 100 data3 = np.array([(2, x) for x in data3]) boxplot = wxplot.BoxPlot(data1, legend="0.0: Weights") boxplot2 = wxplot.BoxPlot(data2, legend="1.0: Heights") boxplot3 = wxplot.BoxPlot(data3, legend="2.0: GammaDistribution") return wxplot.PlotGraphics([boxplot, boxplot2, boxplot3], "Box Plot", "", "Value")
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()
def __init__(self, parent, properties=None, attProperties=None, *args, **kwargs): if not _Numeric: raise ImportError( "numpy.oldnumeric is not present, so dLinePlot cannot instantiate." ) self._plotManager = plot.PlotGraphics([]) self._baseClass = dLinePlot plot.PlotCanvas.__init__(self, parent) name, _explicitName = self._processName(kwargs, self.__class__.__name__) cm.dControlMixin.__init__(self, name, properties=properties, attProperties=attProperties, _explicitName=_explicitName, *args, **kwargs) self.SetPointLabelFunc(self.DrawPointLabel) self.setDefaults() if self.Traces: self.Draw(self._plotManager)
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, 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, )
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 __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)
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 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 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 __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 DrawCoincidencePlots(self): """Draw coincidence plots""" for bandIdx in range(len(self.bandList)): self.canvasList[bandIdx].ySpec = "none" lines = [] level = 0.5 lines.append(self.DrawInvisibleLine(level)) cats = self.stats_data.GetCategories() for i, cat in enumerate(cats): stat = self.stats_data.GetStatistics(cat) if not stat.IsReady(): continue color = stat.color level = i + 1 line = self.DrawCoincidenceLine(level, color, stat.bands[bandIdx]) lines.append(line) # invisible level += 0.5 lines.append(self.DrawInvisibleLine(level)) plotGraph = plot.PlotGraphics(lines, title=self.bandList[bandIdx]) self.canvasList[bandIdx].Draw(plotGraph)
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 DrawHistograms(self, statistics): """Draw histograms for one class :param statistics: statistics for one class """ self.histogramLines = [] for bandIdx in range(len(self.bandList)): self.canvasList[bandIdx].Clear() self.canvasList[bandIdx].ySpec = "auto" histgramLine = self.CreateHistogramLine( bandValues=statistics.bands[bandIdx]) meanLine = self.CreateMean(bandValues=statistics.bands[bandIdx]) minLine = self.CreateMin(bandValues=statistics.bands[bandIdx]) maxLine = self.CreateMax(bandValues=statistics.bands[bandIdx]) self.histogramLines.append( [histgramLine, meanLine, minLine, maxLine]) maxRangeLine = self.CreateMaxRange( bandValues=statistics.bands[bandIdx]) minRangeLine = self.CreateMinRange( bandValues=statistics.bands[bandIdx]) plotGraph = plot.PlotGraphics( self.histogramLines[bandIdx] + [minRangeLine, maxRangeLine], title=self.bandList[bandIdx], ) self.canvasList[bandIdx].Draw(plotGraph)
def _draw9Objects(): """ Histogram The following must be true: len(bspec) = len(hist_data) + 1 """ data = 2.25 * np.random.randn(50) + 3 heights, bins = np.histogram(data, bins=10) hist_fixed_binsize = wxplot.PolyHistogram(heights, bins) # Bins can also be arbitrary widths: hist_variable_binsize = wxplot.PolyHistogram( [2, 3, 4, 6, 3], [18, 19, 22, 25, 26, 27], fillcolour=wx.BLUE, edgewidth=2, edgecolour=wx.RED, ) return wxplot.PlotGraphics( [hist_fixed_binsize, hist_variable_binsize], "Histogram with fixed binsize (left) and variable binsize (right)", "Value", "Count", )
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)