def myLineBoxTextBorder(x, y, lcolor, lstyle, bcolor, bstyle, bsize, tsize, text): l = TLatex() l.SetTextAlign(12) l.SetTextSize(tsize/2.5) l.SetNDC() l.DrawLatex(x,y,text) yl1 = y-0.25*bsize yl2 = y+0.25*bsize xl1 = x-0.25*bsize-0.4*bsize xl2 = x+0.25*bsize-0.4*bsize #print "line = ",xl1,yl1,xl2,yl2 mline = TLine(xl1,yl1,xl2,yl2) mline.SetLineColor(lcolor) mline.SetLineStyle(lstyle) mline.SetLineWidth(2) y_new=(yl1+yl2)/2. mline.DrawLineNDC(xl1,y_new,xl2,y_new) yb1 = y-0.15*bsize yb2 = y+0.15*bsize xb1 = x-0.25*bsize-0.4*bsize xb2 = x+0.25*bsize-0.4*bsize #print "box = ",xb1,yb1,xb2,yb2 mbox = TPave(xb1,yb1,xb2,yb2,1,"NDC") mbox.SetLineWidth(2) mbox.SetLineColor(1) mbox.SetFillColor(bcolor) mbox.SetFillStyle(bstyle) mbox.Draw("l") return mbox
def myBoxText(x,y,boxsize,mcolor,text): tsize=0.06; l=TLatex(); l.SetTextAlign(12); l.SetNDC(); l.DrawLatex(x,y,text); y1=y-0.25*tsize; y2=y+0.25*tsize; x2=x-0.3*tsize; x1=x2-boxsize; mbox= TPave(x1,y1,x2,y2,0,"NDC"); mbox.SetFillColor(mcolor); mbox.SetFillStyle(1001); mbox.Draw(); mline=TLine() mline.SetLineWidth(4) mline.SetLineColor(1) mline.SetLineStyle(1) y=(y1+y2)/2. mline.DrawLineNDC(x1,y,x2,y)
def myBoxText(x, y, boxsize, mcolor, text, tsize=0.06): l = TLatex() l.SetTextAlign(12) l.SetTextSize(tsize) l.SetNDC() l.DrawLatex(x, y, text) y1 = y - 0.25 * tsize y2 = y + 0.25 * tsize x2 = x - 0.3 * tsize x1 = x2 - boxsize mbox = TPave(x1, y1, x2, y2, 0, "NDC") mbox.SetFillColor(mcolor) mbox.SetFillStyle(1001) mbox.Draw() mline = TLine() mline.SetLineWidth(8) mline.SetLineColor(mcolor) mline.SetLineStyle(1) y = (y1 + y2) / 2. mline.DrawLineNDC(x1, y, x2, y)
from ROOT import TCanvas, TPaveLabel, TPave, TLine, TArrow, TText, TPaveText from ROOT import gROOT gROOT.Reset() c1 = TCanvas( 'c1', 'ROOT File description', 200, 10, 700, 550 ) c1.Range( 0, -0.25, 21, 14 ) title = TPaveLabel( 5, 12, 15, 13.7, c1.GetTitle() ) title.SetFillColor( 16 ) title.Draw() # horizonthal file layout file = TPave( 1, 8.5, 20, 11 ) file.SetFillColor( 11 ) file.Draw() fileh = TPave( 1, 8.5, 2.5, 11 ) fileh.SetFillColor( 44 ) fileh.Draw() lrh = TPave( 2.5, 8.5, 3.3, 11, 1 ) lrh.SetFillColor( 33 ) lrh.Draw() lrh.DrawPave( 6.9, 8.5, 7.7, 11, 1 ) lrh.DrawPave( 10.5, 8.5, 11.3, 11, 1 ) lrh.DrawPave( 14.5, 8.5, 15.3, 11, 1 ) ldot = TLine( 1, 8.5, 0.5, 6.5 ) ldot.SetLineStyle( 2 ) ldot.Draw() ldot.DrawLine( 2.5, 8.5, 9.4, 6.5 ) ldot.DrawLine( 10.5, 8.5, 10, 6.5 )
def makeMultiPlot(self): from ROOT import gROOT, gStyle, TFile, TTree, gDirectory from ROOT import TGraphErrors, TCanvas, TLegend, TH2D, TLatex, TPave from operator import itemgetter rangey=(self.args.miny, self.args.maxy) rangex=(self.args.minx, self.args.maxx) ## Build caselist caselist = [] for filename in self.filelist: caselist.append(path.dirname(filename).split('/')[-1]) gROOT.SetBatch() gStyle.SetOptStat(0) oname = self.args.outputName if oname.endswith('.pdf') or oname.endswith('.png'): oname = oname[:-4] if len(oname)==0: ## default oname = 'plot_' + reduce(lambda x,y:x+'_'+y, caselist) canv = TCanvas(oname, "Plot", 0, 0, 1024, 768) canv.cd() if not self.args.nologx: canv.SetLogx() if self.args.logy: canv.SetLogy() canv.SetGridx() canv.SetGridy() ## Cosmetics # canv.DrawFrame(rangex[0], rangey[0], rangex[1], rangey[1]) axes = TH2D('axes', 'A', 100, rangex[0], rangex[1], 100, rangey[0], rangey[1]) title = args.title if len(args.title) else 'Throughput vs. Fragment Size' titleX = args.titleX if len(args.titleX) else 'Fragment Size (bytes)' titleY = args.titleY if len(args.titleY) else 'Av. Throughput per RU (MB/s)' axes.GetYaxis().SetTitle(titleY) axes.GetYaxis().SetTitleOffset(1.4) axes.GetXaxis().SetTitleOffset(1.2) axes.SetTitle(title) axes.GetXaxis().SetTitle(titleX) axes.GetXaxis().SetMoreLogLabels() axes.GetXaxis().SetNoExponent() axes.Draw() tl = TLatex() tl.SetTextFont(42) tl.SetNDC(1) if len(self.args.tag) > 0: width = 0.12+0.020*len(self.args.tag) if width > 0.9: width=0.899 pave = TPave(0.12, 0.80, width, 0.899, 0, 'NDC') pave.SetFillStyle(1001) pave.SetFillColor(0) pave.Draw() if len(self.args.subtag) > 0: width2 = 0.12+0.015*len(self.args.subtag) if width2 > 0.9: width2=0.899 pave2 = TPave(0.12, 0.75, width2, 0.899, 0, 'NDC') pave2.SetFillStyle(1001) pave2.SetFillColor(0) pave2.Draw() if len(self.args.tag) > 0: tl.SetTextSize(0.05) tl.DrawLatex(0.14, 0.83, self.args.tag) if len(self.args.subtag) > 0: tl.SetTextSize(0.035) tl.DrawLatex(0.145, 0.77, self.args.subtag) graphs = [] configs = set() for filename,case in zip(self.filelist,caselist): try: graphs.append(self.getGraph(filename)) config, builder, protocol, rms = extractConfig(filename) nstreams, nrus, nbus, strperfrl = getConfig(config) if strperfrl == 0: nrus = 1 ## ignore number of RUs if MSIO configs.add(nrus) else: configs.add(nstreams//nrus) ## care only about Nstreams per RU except AttributeError: print "#### Couldn't get graph for ", case, "in file", filename return if not self.args.hideDate: datepave = drawDate(self.filelist[0]) datepave.Draw() # if self.args.daq1: # daq1_graph = getDAQ1Graph() configs = sorted(configs) nlegentries = len(self.filelist) # nlegentries = len(caselist) if not self.args.daq1 else len(caselist) + 1 legendpos = (0.44, 0.13, 0.899, 0.20+nlegentries*0.05) maxentrylength = 0.04 if self.args.legend: maxentrylength = max(len(x) for x in self.args.legends) legxlength = min(max(maxentrylength*0.013, 0.18),0.6) if strperfrl == 0: legendpos = (0.13, 0.73, 0.13+legxlength, 0.73-nlegentries*0.045) # if self.args.legendPos == 'TL': # legendpos = (0.12, 0.82-nlegentries*0.05, 0.579, 0.898) # # legendpos = (0.12, 0.71-nlegentries*0.05, 0.579, 0.78) leg = TLegend(legendpos[0], legendpos[1], legendpos[2], legendpos[3]) leg.SetFillStyle(1001) leg.SetFillColor(0) leg.SetTextFont(42) leg.SetTextSize(0.033) leg.SetBorderSize(0) colors = [1,2,3,4,51,95,65,39,32] markers = [20,21,22,23,34,33,29,24,25,26] if (len(self.args.legends) > 0 and len(self.args.legends) != len(self.filelist)): print "Legends doesn't match with filelist, falling back to default" for n,graph in enumerate(graphs): graph.SetLineColor(colors[n]) graph.SetMarkerColor(colors[n]) graph.SetMarkerStyle(markers[n]) ## Custom legends if (len(self.args.legends) == len(self.filelist) and len(self.args.legends)>0): leg.AddEntry(graph, self.args.legends[n], 'P') else: ## Default leg.AddEntry(graph, caselist[n], 'P') # if self.args.daq1: # leg.AddEntry(daq1_graph, 'DAQ1 (2011)', 'P') graph.Draw("PL") # if self.args.daq1: # daq1_graph.Draw("PL") if not self.args.noRateLine: for n,streams_per_ru in enumerate(configs): func = getRateGraph(streams_per_ru, frag=True, rate=self.args.rate, xmax=rangex[1]) func.SetLineColor(colors[n]) func.SetLineWidth(1) func.DrawCopy("same") if not strperfrl == 0: leg.AddEntry(func, '%.0f kHz (%d streams)'% (self.args.rate, streams_per_ru), 'l') else: leg.AddEntry(func, '%.0f kHz'% (self.args.rate), 'l') leg.Draw() for graph in graphs: graph.Draw("PL") canv.Print(oname + '.pdf') canv.Print(oname + '.png')