// $Id: Example6.C,v 1.1 2010/07/18 16:36:31 videbaek Exp $ // // This simple example divides a canvas into 2 pad (nx*ny) // illustrates how to detup the offsets, and draw text with a given size. // void Example6(int opt=1){ gSystem->Load("../.libs/libGrUtils.so"); gROOT->ProcessLine("using namespace GraphUtils"); gROOT->LoadMacro("../BasePlot.C+"); savePNG=1; TH1F* h1 = new TH1F("h1","spec1",40,0,4.0); int i(3); for(double x=0.25;x<4.0;x+=0.1){ double f = TMath::Exp(-x*5.0)*1000; double df= TMath::Sqrt(f); f = gRandom->Gaus(f,df); h1->SetBinContent(i,f); h1->SetBinError(i,df); i++; } TGraphAsymmErrors* gr = new TGraphAsymmErrors(h1); for(int b=0;b< gr->GetN(); b++){ double x,y; gr->GetPoint(b,x,y); gr->SetPointEYhigh(b,0.6*y); gr->SetPointEYlow(b,0.2*y); } // // create 4 histograms from a kind of fct // SetupPage(4.5*2.54, 6.0*2.54); SetupCanvas("TestPlot","Test Plot Example6"); bottomMargin=0.06; leftMinorMargin=0.005; bottomMinorMargin=0.03; topMargin=0.06; rightMinorMargin=0.005; rightMargin=0.12; if(opt) { leftJustify=1; botJustify=1; } titleYOffset=1.3; titleXOffset=0.45; fLegendLineColor=1; int nx(2), ny(3); double fdy[] = {2,1,1}; double fdx[] = {2,1}; InitPads(nx,ny, fdx, fdy); SetMarkerStyle(21); SetMarkerColor(kRed); SetLineColor(kRed); useScaling = kTRUE; useIncrement=kTRUE; scaleFactor=0.1; Float_t frameMax = 999.; Float_t nDec = 4; Float_t frameMin = frameMax*TMath::Power(10.,-nDec); xTitle = "p_{T} (GeV/c)"; yTitle = "#frac{1}{2#pi p_{T}} #frac{d^{2}N}{dp_{T}dy} (GeV/c)^{-2}"; xNDiv = 1003; yNDiv = 510; CreateFrame(0,0, 0.000, 2.9999, frameMin, frameMax, 0, 1); CreateFrame(1,0, 0.000, 2.9999, frameMin, frameMax, 0, 1); frameMin = frameMax*TMath::Power(10.,-nDec/2); CreateFrame(0,1, 0.000, 2.9999, frameMin, frameMax, 0, 1); CreateFrame(1,1, 0.000, 2.9999, frameMin, frameMax, 0, 1); frameMax=2; frameMin=0; CreateFrame(0,2, 0.000, 2.9999, frameMin, frameMax, 0, 0); CreateFrame(1,2, 0.000, 2.9999, frameMin, frameMax, 0, 0); GetPad(0,2)->SetTicks(2,1); GetPad(0,1)->SetTicks(1,0); GetPad(1,2)->SetTicks(2,2); GetPad(1,1)->SetTicks(1,1); AddHistogram(0, h1,"#pi h1","e"); AddSystErr(0, gr, -1., 34, 2001); SetMarkerColor(kBlue); SetLineColor(kBlue); currentScale = 1; DrawPads(); Float_t padx = GetPadX(1); Float_t pady = GetPadY(0); PlotText(GetPad(1,0), padx/2., pady-0.4,"Pad 1,0",0.3)->SetTextColor(kBlue); Float_t padx = GetPadX(1); Float_t pady = GetPadY(2); PlotText(GetPad(1,2), padx/2., pady-0.4,"Pad 1,2",0.3)->SetTextColor(kBlue); SaveFigure("example5"); }