// $Id: Example4.C,v 1.3 2009/09/12 17:03:19 videbaek Exp $ // // Example to check settin of tick mark/lables on top/side of graphs // with topMargin set to non-zero. // { gSystem->Load("../.libs/libGrUtils.so"); gROOT->ProcessLine("using namespace GraphUtils"); gROOT->LoadMacro("../BasePlot.C+"); 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 histograms from a kind of fct // SetupPage(4.5*2.54, 3.0*2.54); SetupCanvas("TestPlot","Test Plot Example4"); bottomMargin=0.12; leftMinorMargin=0.0; bottomMinorMargin=0.00; topMargin=0.06; rightMargin=0.1; leftJustify=1; botJustify=1; titleYOffset=1.0; titleXOffset=0.45; fLegendLineColor=1; int nx(1), ny(1); InitPads(nx,ny); SetMarkerStyle(21); SetMarkerColor(kRed); SetLineColor(kRed); useScaling = kTRUE; useIncrement=kTRUE; scaleFactor=0.1; Float_t frameMax = 999; Float_t nDec = 5; Float_t frameMin = frameMax*TMath::Power(10.,-nDec); xTitle = "p_{T} (GeV/c)"; yTitle = "#frac{1}{2#pi cp_{T}} #frac{d^{2}N}{dp_{T}dy} (GeV/c)^{-2}"; xNDiv = 1003; yNDiv = 510; CreateFrames(0.000, 2.9999, frameMin, frameMax, 0, 1); GetPad(0,0)->SetTicks(2,2); SetupLegend(0, 0, 5.0, 3.6, 1.0, 1.0, 0.3); AddHistogram(0, h1,"#pi h1","e"); AddSystErr(0, gr, -1., 34, 2001); SetMarkerColor(kBlue); SetLineColor(kBlue); currentScale = 1; DrawPads(); TLatex* text = PlotText(0, 0, 2.0, 5.0,"Graph Asymm errors as: AddSystErr(0, gr, -1., 34,2001)", 0.2 ); text->SetTextColor(kOrange); savePNG=1; SaveFigure("Example4"); }