def plot(complex_lst): ## plot the cluster rmsd dist. plot = biggles.FramedPlot() inset = biggles.FramedPlot() ## plot title plot.title = '/'.join(string.split(absfile(options['o']), '/')[-5:-1]) ## customize plot appearence plot.x1.label = 'cluster' plot.y2.label = 'size' plot.y1.label = 'rmsd' plot.x2.draw_ticks = 0 plot.y2.draw_ticks = 0 inset.frame.draw_ticks = 0 inset.x1.draw_ticklabels = 0 inset.y1.draw_ticklabels = 0 inset.y2.draw_ticklabels = 1 inset.y2.draw_ticks = 1 inset.y2.ticks_style['color'] = 'red' ## get cluter and rmsd lists clst_list = [] rms_list = [] for compl in complex_lst: clst_list += [compl.info['hex_clst']] rms_list += [compl.info['rms']] ## get average, max, min and size of cluster data = [] clst_range = range(1, max(clst_list) + 1) for clst in clst_range: rms = compress(equal(clst_list, clst), rms_list) data += [[average(rms), max(rms), min(rms), len(rms)]] data = transpose(data) ## Inset inset.add(biggles.Curve(clst_range, data[3], color='red')) ## Plot plot.add(biggles.ErrorBarsY(clst_range, data[1], data[2])) plot.add(biggles.Points(clst_range, data[0], type='cross', size=1)) plot.add(biggles.Inset((0.0, 0.0), (1.0, 1.0), inset)) plot.add(biggles.LineY(10, type='dot')) ## add label with info about 'good' solutions (average rmsd < 10A) good = [] for clst in clst_range: if data[0][clst - 1] < 10: good += [clst] plot.add(biggles.PlotLabel(0.5, 0.98, 'Solutions with rmsd < 10A', size=1)) plot.add(biggles.PlotLabel(0.5, 0.95, str(good), size=1)) ## plot and save plot.show() plot.write_eps(string.split(options['o'], '.')[0] + '.eps')
def lookat(year, week): p = biggles.FramedPlot() hack = 3 if year % 2000 == 2: hack = 2 start = time.mktime(time.strptime("%02d %03d" % (year % 2000, (week * 7)+hack), "%y %j")) end = start + 604800. l = makelines(start, end) if l != None: p.add(biggles.FillBelow(l[0], l[1], color="gray")) l = makelines(start, end, 'p') if l != None: p.add(biggles.FillBelow(l[0], l[1], color="light blue")) l = makelines(start, end, 'c') if l != None: p.add(biggles.FillBelow(l[0], l[1], color="green")) l = makelines(start, end, 's') if l != None: p.add(biggles.FillBelow(l[0], l[1], color="red")) l = makelines(start, end, 'h') if l != None: p.add(biggles.FillBelow(l[0], l[1], color="purple")) for s in scandef: makelines2(start, end, s, p) p.x2.label = "Week of "+time.strftime("%a %d %B %Y", time.localtime(start)) p.y1.range = 0, 1 p.y1.draw_ticklabels = 0 p.x1.range = 0, 604800 p.x2.ticks = map(lambda x: x*604800./7. + 604800./7./2., range(7)) p.x2.ticklabels = ["Wed", "Thu", "Fri", "Sat", "Sun", "Mon", "Tue"] p.x1.ticks = map(lambda x: x*604800./7., range(8)) p.x1.ticklabels = map(firstafter, map(lambda x: x*604800./7. + start, range(8))) p.aspect_ratio = 0.15 return p
def test_example2(self): p = biggles.FramedPlot() p.xrange = 0, 100 p.yrange = 0, 100 p.aspect_ratio = 1 x = numpy.arange(0, 100, 5) yA = numpy.random.normal(40, 10, size=len(x)) yB = x + numpy.random.normal(0, 5, size=len(x)) a = biggles.Points(x, yA, type="circle") a.label = "a points" b = biggles.Points(x, yB) b.label = "b points" b.style(type="filled circle") l = biggles.Slope(1, type="dotted") l.label = "slope" k = biggles.PlotKey(.1, .9) k += a k += b, l p.add(l, a, b, k) _write_example(2, p)
def plot_fofs(m, fof, plotfile, minsize=2): """ make an ra,dec plot of the FOF groups Only groups with at least two members ares shown """ try: import biggles import esutil as eu have_biggles=True except ImportError: have_biggles=False if not have_biggles: print("skipping FOF plot because biggles is not " "available") return hd=eu.stat.histogram(fof['fofid'], more=True) wlarge,=numpy.where(hd['hist'] >= minsize) ngroup=wlarge.size colors=rainbow(ngroup) ffront=os.path.basename(plotfile) name=ffront.split('-mof-')[0] title='%s FOF groups' % name aratio = (m['dec'].max()-m['dec'].min())/(m['ra'].max()-m['ra'].min()) plt=biggles.FramedPlot( xlabel='RA', ylabel='DEC', title=title, aspect_ratio=aratio, ) allpts=biggles.Points( m['ra'], m['dec'], type='dot', ) plt.add(allpts) rev=hd['rev'] icolor=0 for i in xrange(hd['hist'].size): if rev[i] != rev[i+1]: w=rev[ rev[i]:rev[i+1] ] if w.size >= minsize: indices=fof['number'][w]-1 color=colors[icolor] pts = biggles.Points( m['ra'][indices], m['dec'][indices], type='circle', size=1, color=color, ) plt.add(pts) icolor += 1 print("writing:",plotfile) plt.write_img(1500,int(1500*aratio),plotfile)
def prepare_plot( xlabel='', ylabel='', yrange=None, xrange=None, width=500, height=350 ): """ Initiate a biggles.FramedPlot object. @param xlabel: label for x-axis @type xlabel: str @param ylabel: label for y-axis @type ylabel: str @param yrange: range of y-axis @type yrange: (float,float) @param xrange: range of x-axis @type xrange: (float,float) @param width: hard plot width (in pixels or cm) @type width: int @param height: hard plot height @type height: int @return: biggles plot object @rtype: biggles.FillBetween """ B.configure( 'screen', 'height', height ) B.configure( 'screen', 'width', width ) p = B.FramedPlot() p.xlabel = xlabel p.ylabel = ylabel if yrange: p.yrange = yrange if xrange: p.xrange = xrange return p
def plot_stats(stats, name=""): ''' Plots the population's average and best fitness. Lisa Meeden added a name parameter for handling multiple visualizations in co-evolution. ''' if has_biggles: generation = [i for i in xrange(len(stats[0]))] fitness = [fit for fit in stats[0]] avg_pop = [avg for avg in stats[1]] plot = biggles.FramedPlot() plot.title = "Population's average and best fitness" plot.xlabel = r"Generations" plot.ylabel = r"Fitness" plot.add(biggles.Curve(generation, fitness, color="red")) plot.add(biggles.Curve(generation, avg_pop, color="blue")) #plot.show() # X11 plot.write_img(600, 300, name+'avg_fitness.svg') # width and height doesn't seem to affect the output! else: print 'You dot not have the Biggles package.'
def use_cross_section(csfunc, filename): hads = [] hads_err = [] for r in testsample: c, e = csfunc(r) hads.append(c) hads_err.append(e) hads_center = jt.wmean(zip(hads, hads_err))[0] p = biggles.FramedPlot() p.add( biggles.Points(range(len(testsample)), Numeric.array(hads) / hads_center, type="filled circle")) p.add( biggles.SymmetricErrorBarsY(range(len(testsample)), Numeric.array(hads) / hads_center, Numeric.array(hads_err) / hads_center)) p.x1.draw_ticklabels = 0 p.x1.label = "Runs by index" p.y1.label = "Normalized hadronic cross-section" p.add(biggles.LineY(1.)) p.add(biggles.LineX(41.5, type="dashed")) l, r = 0.8, 1.2 p.yrange = l, r + 0.001 p.add(biggles.DataLabel(41.5 - 10, l + 0.15 * (r - l), "db16")) p.add(biggles.DataLabel(41.5 + 10, l + 0.15 * (r - l), "db17")) p.aspect_ratio = 8.5 / 11. p.show() p.write_eps(filename)
def plotKey(data, name, key): ## plot the cluster rmsd dist. plot = biggles.FramedPlot() plot.add(biggles.PlotLabel(0.5, 0.90, name, size=4)) ## customize plot appearence #plot.x1.label = 'cluster' plot.y2.label = 'size' plot.y1.label = key plot.x2.draw_ticks = 0 plot.y2.draw_ticks = 0 ## Plot plot.add( biggles.ErrorBarsY(clst_range, data[key][1], data[key][2], width=1)) plot.add(biggles.Points(clst_range, data[key][0], type='cross', size=1)) plot.add(biggles.LineY(0.25, type='dot')) ## add label with info about 'good' solutions good = [] for clst in clst_range: if data[key][0][clst - 1] > 0.25: good += [clst] plot.add(biggles.PlotLabel(0.5, 0.80, str(good), size=1)) return plot
def plotInfo(info): """ biggles FramedArray with only information labels """ stat = biggles.FramedPlot() #stat.title = 'grouping info' ## turn off drawing of all axis related objects ## note: if all is turned off plotting doesnt work, so make one white stat.x.draw_ticks = 0 stat.y.draw_ticks = 0 stat.x.draw_ticklabels = 0 stat.y.draw_ticklabels = 0 stat.y.draw_spine = 0 stat.x.spine_style['color'] = 'white' ## have to make it a plot - add a white line stat.add(biggles.LineY(0.01, type='dot', color='white')) ## add info lines one by one (from bottom and up!) info = string.split(info, '\n') for l in range(len(info)): yPos = 0.95 - 0.04 * l stat.add( biggles.PlotLabel( .05, yPos, info[l], halign='left', \ size=1, face='courier' ) ) return stat
def generarSalida(self, valoresFitness, numGeneracion): filename = "%stxtGraph_%s.txt" % (self.OUTPUT_PATH, str(numGeneracion)) if (self.TIPO_SALIDA == "TEXT"): to_print = [] to_print.append("#Generado por GenErik (c) 2008 Erik Giron") to_print.append("#Generacion %d\n" % numGeneracion) to_print.append("#Total Poblacion " + str(len(valoresFitness)) + "\n\n") to_print.append("#Peso:\tBeneficio:\n") for (x, y) in valoresFitness: to_print.append(" %f\t%f\n" % (x, y)) FILE = open(filename, "w") FILE.writelines(to_print) FILE.close() if (self.TIPO_SALIDA == "MOVIE"): x = [] #biggles.read_column ( 0, filename, float, '#' ) y = [] #biggles.read_column ( 1, filename, float, '#' ) for i, j in valoresFitness: x.append(i) y.append(j) g = biggles.FramedPlot() g.xrange = (0, self.MAX_PESO * self.MAX_GENES) g.yrange = (0, self.MAX_BENEFICIO * self.MAX_GENES) pts = biggles.Points(x, y) #biggles.Points( x, y) #line = biggles.Curve(x, y) g.add(pts) g.xlabel = "Peso total" g.ylabel = "Beneficio total" g.title = "Grafo para Generacion %d\n Por GenErik (c) 2008 Erik Giron" % numGeneracion g.write_img( 512, 384, "%sgenGraph%03d.png" % (self.OUTPUT_PATH, numGeneracion))
def plot_species(species_log, name=""): ''' Visualizes speciation throughout evolution. Lisa Meeden added a name parameter for handling multiple visualizations in co-evolution. ''' plot = biggles.FramedPlot() plot.title = "Speciation" plot.ylabel = r"Size per Species" plot.xlabel = r"Generations" generation = [i for i in range(len(species_log))] species = [] curves = [] for gen in range(len(generation)): for j in range(len(species_log), 0, -1): try: species.append(species_log[-j][gen] + sum(species_log[-j][:gen])) except IndexError: species.append(sum(species_log[-j][:gen])) curves.append(species) species = [] s1 = biggles.Curve(generation, curves[0]) plot.add(s1) plot.add(biggles.FillBetween(generation, [0]*len(generation), generation, curves[0], color=random.randint(0,90000))) for i in range(1, len(curves)): c = biggles.Curve(generation, curves[i]) plot.add(c) plot.add(biggles.FillBetween(generation, curves[i-1], generation, curves[i], color=random.randint(0,90000))) plot.write_img(1024, 800, name+'speciation.svg')
def test(self, nrand=500000): """ Generate some randoms and compare to input distribution """ import biggles x = self.xinput if self.isfunc: y = self.pofx(x) else: y = self.pofx # generate some randoms rand = self.genrand(nrand) # make the histogram at the binsize of the # xinput binsize = x[1] - x[0] h = eu.stat.histogram(rand, min=x[0], max=x[-1], binsize=binsize) # since on same grid can normalize simply h = h / float(h.sum()) y = y / float(y.sum()) plt = biggles.FramedPlot() py = biggles.Histogram(y, x0=x[0], binsize=binsize) ph = biggles.Histogram(h, x0=x[0], binsize=binsize, color='red') plt.add(py, ph) plt.show()
def test(self, nrand=500000): """ Generate some randoms and compare to input distribution """ import biggles # generate some randoms rand = self.genrand(nrand) std = rand.std() binsize = std * 0.05 xvals = numpy.arange(self.xmin, self.xmax, binsize) yvals = self.pofx(xvals) h = eu.stat.histogram(rand, min=xvals[0] - binsize / 2, max=xvals[-1] + binsize / 2, binsize=binsize) # since on same grid can normalize simply h = h / float(h.sum()) yvals = yvals / float(yvals.sum()) plt = biggles.FramedPlot() py = biggles.Histogram(yvals, x0=xvals[0], binsize=binsize) ph = biggles.Histogram(h, x0=xvals[0], binsize=binsize, color='red') plt.add(py, ph) plt.show()
def plot_stats_biggles(stats, candidate_util, dest_dir='.'): if HAS_BIGGLES: generation = [i for i in range(len(stats[0]))] fitness = [candidate_util.get_candidate_fitness(c) \ if candidate_util.get_candidate_fitness(c) is not None \ else 0 for c in stats[0]] avg_pop = [avg if avg is not None else 0 for avg in stats[1]] plot = biggles.FramedPlot() plot.title = "Population's average and best fitness" plot.xlabel = r"Generations" plot.ylabel = r"Fitness" plot.add(biggles.Curve(generation, fitness, color="red")) plot.add(biggles.Curve(generation, avg_pop, color="blue")) # plot.show() # X11 try: plot.write_img(1300, 800, os.path.join(dest_dir, 'avg_fitness.png')) except Exception: print(traceback.format_exc()) # width and height doesn't seem to affect the output! else: print('You do not have the Biggles package.')
def main10(): amp = 16385 Tao = 10E-6 Ts = 1E-8 m1 = 297 m2 = 0.297 #0.0515 noi = 0 t, s = Signal(Ts, Tao, amp=amp) snoise = noise(s, noi) spz = poleZero(snoise, Tao, Ts) rn, sn = trapez(spz, m1, m2) max_ = PHA(sn) print np.floor(sn[0:100]) print max_ import biggles p = biggles.FramedPlot() p.add(biggles.Curve(np.arange(sn.shape[0])[20:70], sn[20:70], color='blue')) p.add(biggles.Slope(0, color='green')) p.show()
def test_example6(self): x = numpy.arange(1 * numpy.pi, 3 * numpy.pi, numpy.pi / 30) c = numpy.cos(x) s = numpy.sin(x) p = biggles.FramedPlot() p.aspect_ratio = 1 p.frame1.draw_grid = 1 p.frame1.tickdir = 1 p.x1.label = "bottom" p.x1.subticks = 1 p.y1.label = "left" p.y1.draw_spine = 0 p.x2.label = "top" p.x2.range = 10, 1000 p.x2.log = 1 p.y2.label = "right" p.y2.draw_ticks = 0 p.y2.ticklabels = ["-1", "-1/2", "0", "1/2", "1"] p.add(biggles.Curve(x, c, type='dash')) p.add(biggles.Curve(x, s)) _write_example(6, p)
def plot( delta_scores_1, delta_rms_1, delta_scores_2, delta_rms_2, feps ): """ """ p = B.FramedPlot() p.xlabel = r"Interface rmsd to bound relative to free" p.ylabel = r"Docking performance relative to free" points_1 = B.Points( delta_rms_1, delta_scores_1, type='circle', symbolsize=1) points_1.label = 'MD' points_2 = B.Points( delta_rms_2, delta_scores_2, type='diamond', symbolsize=1) points_2.label = 'PCR-MD' a = concatenate( (delta_rms_1, delta_rms_2) ) h = density( a, 20 ) scale = max( h[:,1] ) / max( a ) histogram = B.Curve( h[:,0], h[:,1] * scale ) histogram.label = "distribution" p.add( points_1 ) p.add( points_2 ) p.add( histogram ) p.add( B.PlotKey( 0.73, 0.95, [ points_1, points_2, histogram ] ) ) p.show() p.write_eps( feps )
def main(): pulse = GenPulse() pulse.setPmtComps() pulse.calcConstants() pulse.initLists() #pulse.calcPulseExp() pulse.calcPulseTri() pulse.calcPmtOut() time, out = pulse.calcADCOut(3) #pulse.differential() import copy tmp = copy.copy(pulse.pulseOut) #pulse.integra() pulse.amplifier(1.0 / 256.0) pulse.integra() tw = twc.TwoCompl(16) #twl = tw.toFile(pulse.pulseOut, "vector.tv") plt = biggles.FramedPlot() plt.add(biggles.Curve(time, pulse.expPulse, color="black")) plt.show()
def make_coloredpoints_plot(): # This is the magic recipe for an array of points from (0,0) to (10,10) (x, y) = numpy.reshape(numpy.indices([10 + 1, 10 + 1]), (2, -1)) # Let's color the points by their distance from the point (3,7) center = (3, 7) rad = mag(numpy.transpose([x, y]) - center) scaledrad = (1 - rad / numpy.max(rad))[:, numpy.newaxis] # Go from light blue to intense red. minColor = numpy.array([0.6, 0.9, 1.0]) maxColor = numpy.array([1.0, 0.2, 0.2]) colorrad = minColor + scaledrad * (maxColor - minColor) cp = biggles.ColoredPoints(x, y, colorrad, type='filled circle', size=6) # make plot p = biggles.FramedPlot() p.title = "Colored Points Plot" p.add(cp) return p
def main(): # import pycat # model = pycat.Zilany2009 # pars = { 'powerlaw_implnt':'approx', # 'with_ffGn':False } # fs = 100e3 import cochlea model = cochlea.Sumner2003 pars = {} fs = 100e3 # import cochlea # model = cochlea.Holmberg2007 # fs = 48000 import traveling_waves as tw cf = tw.real_freq_map[68] # print _run_model( (model, cf, 48000, 3000, 50, {}) ) # exit() rates = calc_isointensity_curves(model, cf, fs=fs, **pars) print rates import biggles p = biggles.FramedPlot() p.xlog = 1 for dbspl in np.unique(rates['dbspl']): selected = rates[rates['dbspl'] == dbspl] p.add(biggles.Curve(selected['freq'], selected['hsr_rate'])) p.show()
def show(self, fileName=None): """ Show ramachandran plot. """ plot = biggles.FramedPlot() plot.xrange = (-180., 180.) plot.yrange = (-180., 180.) plot.xlabel = "$\Phi$" plot.ylabel = "$\Psi$" if self.name: plot.title = self.name ## add allowed regions bg_plot = self.ramachandran_background() for p in bg_plot: plot.add(p) ## add ramachandran phi, psi valies points, inset = self.ramachandran() for p in points: plot.add(p) if inset: plot.add(inset) plot.add(biggles.PlotLabel(1.14, 0.55, self.profileName, size=2)) plot.add(biggles.PlotLabel(1.1, 0.45, "GLY star", size=2)) plot.add(biggles.PlotLabel(1.12, 0.40, "PRO square", size=2)) plot.show() if fileName: plot.write_eps(fileName)
def test_xi_converge_nplk(epsfile=None): """ Test how xi converges with the number of k points per log10(k) Note we should test other convergence factors too! """ import biggles tab = biggles.Table(2, 1) pltbig = biggles.FramedPlot() pltzoom = biggles.FramedPlot() pltbig.xlabel = "r" pltbig.ylabel = "xi(r)" pltbig.xlog = True pltbig.ylog = True pltzoom.xlabel = "r" pltzoom.ylabel = "xi(r)" lin = Linear() r = 10.0**np.linspace(0.0, 2.3, 1000) nplk_vals = [20, 60, 100, 140, 160] color_vals = ["blue", "skyblue", "green", "orange", "magenta", "red"] plist = [] lw = 2.4 for nplk, color in zip(nplk_vals, color_vals): print("nplk:", nplk) xi = lin.xi(r, nplk=nplk) limxi = np.where(xi < 1.0e-5, 1.0e-5, xi) climxi = biggles.Curve(r, limxi, color=color, linewidth=lw) climxi.label = "nplk: %i" % nplk pltbig.add(climxi) plist.append(climxi) w, = np.where(r > 50.0) cxi = biggles.Curve(r[w], xi[w], color=color, linewidth=lw) pltzoom.add(cxi) key = biggles.PlotKey(0.7, 0.8, plist) pltzoom.add(key) tab[0, 0] = pltbig tab[1, 0] = pltzoom if epsfile is not None: tab.write_eps(epsfile) else: tab.show()
def _plot_single(data, samples, comps, do_ylog=False): import biggles import esutil as eu import pcolors valmin=data.min() valmax=data.max() std = data.std() binsize=0.05*std ph,be,harr = biggles.make_histc(data, min=valmin, max=valmax, binsize=binsize, ylog=do_ylog, norm=1, get_hdata=True) sample_ph,sbe,sharr= biggles.make_histc(samples, min=valmin, max=valmax, binsize=binsize, color='red', ylog=do_ylog, norm=1, get_hdata=True) ph.label='data' sample_ph.label='fit' key = biggles.PlotKey(0.1, 0.9, [ph, sample_ph], halign='left') plt = biggles.FramedPlot() plt.add( ph, sample_ph, key ) w,=where( (harr > 0) & (sharr > 0) ) yrange=[min(harr[w].min(), sharr[w].min()), 1.1*max(harr[w].max(), sharr[w].max())] if do_ylog: plt.ylog=True # now add the components h,rev=eu.stat.histogram(comps, rev=True) print(h) w,=where(h > 0) ncolors = w.size colors=pcolors.rainbow(ncolors) icolor=0 for i in xrange(h.size): if rev[i] != rev[i+1]: w=rev[ rev[i]:rev[i+1] ] frac=float(w.size)/comps.size ph = biggles.make_histc(samples[w], #min=valmin, max=valmax, binsize=binsize, color=colors[icolor], ylog=do_ylog, norm=frac) plt.add(ph) icolor += 1 plt.yrange=yrange return plt
def test_ColorSpectrum( self ): """ColorSpectrum test""" try: import biskit.tools as T import biggles as B except: B = 0 c_grey = ColorSpectrum( 'grey', 0, 100 ) c_sausage = ColorSpectrum( 'sausage', 0, 100 ) c_plasma = ColorSpectrum( 'plasma', 0, 100 ) c_plasma2 = ColorSpectrum( 'plasma2', 0, 100 ) if B: self.p = B.FramedPlot() ## old_spectrum = T.colorSpectrum( 100 ) self.result = [] for i in range( -1, 100 ): x = (i, i+1 ) if B: self.result += [ c_grey.color( i ) ] self.p.add( B.FillBelow( x, (1., 1.), color = c_grey.color( i ) ) ) self.p.add( B.FillBelow( x, (0.75, 0.75), color = c_sausage.color( i ) ) ) self.p.add( B.FillBelow( x, (0.5, 0.5), color = c_plasma.color( i ) ) ) self.p.add( B.FillBelow( x, (0.25, 0.25), color = c_plasma2.color( i ) ) ) ## self.p.add( B.FillBelow( x, (0., 0.), ## color = old_spectrum[i] )) if B: self.p.add( B.Curve( (0,100), (1.,1.)) ) self.p.add( B.Curve( (0,100), (.75,.75)) ) self.p.add( B.Curve( (0,100), (.5,.5) )) self.p.add( B.Curve( (0,100), (0.25, 0.25)) ) self.p.add( B.Curve( (0,100), (0.0, 0.0)) ) self.p.add( B.PlotLabel( 0.5 ,0.9, 'grey') ) self.p.add( B.PlotLabel( 0.5 ,0.65, 'sausage') ) self.p.add( B.PlotLabel( 0.5 ,0.4, 'plasma') ) self.p.add( B.PlotLabel( 0.5 ,0.15, 'plasma2') ) if (self.local or self.VERBOSITY > 2) and B: self.p.show() ##self.assertEqual(self.result, self.EXPECTED) ## tolerate two differences to account for Python 3 result a = N0.array(self.result) b = N0.array(self.EXPECTED) self.assert_(N0.count_nonzero(a-b)<3)
def plotWindowRate(self, rates): self.mean = biggles.FramedPlot() self.mean.xrange = 0, len(rates) + 1 self.mean.yrange = 0, max(rates) self.mean.xlabel = "Window" self.mean.ylabel = "Fequency (Hz)" self.mean.add(biggles.Curve(numpy.arange(0, len(rates)), rates)) self.rows += 1 self.bPlotMean = True
def test_example12(self): p = biggles.FramedPlot() p.title = "triangle" p.xlabel = r"$x$" p.ylabel = r"$y$" p.add(biggles.Polygon([0, 1, 0.5], [0, 0, 1])) _write_example(12, p)
def draw(t, in_, out): import biggles p = biggles.FramedPlot() p.add(biggles.Curve(t, out, color='blue')) p.add(biggles.Curve(t, in_, color='red')) p.add(biggles.Slope(0, color='green')) p.show()
def test_example8(): # # Create example 2-dimensional data set of two solitons colliding. # n = 64 x = numpy.arange(-10., 10., 20. / n) t = numpy.arange(-1., 1., 2. / n) z = numpy.zeros((len(x), len(t))) for i in range(len(x)): for j in range(len(t)): z[i, j] = -12. * (3. + 4. * numpy.cosh(2. * x[i] - 8. * t[j]) + numpy.cosh(4. * x[i] - 64. * t[j])) / \ (3. * numpy.cosh(x[i] - 28. * t[j]) + numpy.cosh(3. * x[i] - 36. * t[j]))**2 # # Make contour component. # c = biggles.Contours(z, x, t, color="red") # # For fine-grained color control, the Contours component allows you to # specify a function which returns the color applied to each contour line. # The arguments passed to the function are: # # i integer index of contour (0,..,n-1) # n total number of contours # z0 z value of contour # z_min minimum z contour value # z_max maximum z contour value # # The function should return a valid color, or None for the default. # # Here we show how to set every other contour to blue. The remaining # contours are drawn with the default color, defined above to be red. # def even_blue(i, n, z0, z_min, z_max): if i % 2 == 0: return 0x0000ff return None c.func_color = even_blue # # Similarly, Contours accepts similar functions for line type # (.func_linestyle) and width (.func_linewidth). The arguments passed # are the same. # # # Make framed plot container and add contour component. # p = biggles.FramedPlot() p.add(c) _write_example(8, p)
def plotCOV(self, cells, COV): self.cov = biggles.FramedPlot() self.cov.xrange = self.startIdx, self.endIdx + 1 self.cov.yrange = 0, max(COV) self.cov.xlabel = "Cell Index" self.cov.ylabel = "COV" self.cov.add(biggles.Points(cells, COV, type="filled circle")) self.rows += 1 self.bPlotCOV = True
def initPlot(self): """ override for plot creation """ if not biggles: raise ImportError, 'biggles module could not be imported.' self.page = biggles.FramedPlot() self.plot = self.page