From aa9fc4e98ad53d6915150865c5c7bfafaea33308 Mon Sep 17 00:00:00 2001 From: zleba <radek.zlebcik@gmail.com> Date: Sun, 10 Mar 2019 23:25:44 +0100 Subject: [PATCH] Adding pyton example --- .travis.yml | 1 + RemoveOverlaps.h | 20 ++++++++++---------- test.py | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 test.py diff --git a/.travis.yml b/.travis.yml index 9b559ab..a71e19e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ script: - ./rd make all test - ./rd ./test && mv testGrid.pdf testGrid1.pdf - ./rd root -l -b -q test.C && mv testGrid.pdf testGrid2.pdf + - ./rd python test.py && mv testGridPy.pdf testGridPy.pdf - mkdir public && cp *.pdf public deploy: diff --git a/RemoveOverlaps.h b/RemoveOverlaps.h index ad2c1c5..ee28d7b 100644 --- a/RemoveOverlaps.h +++ b/RemoveOverlaps.h @@ -740,7 +740,7 @@ void PaintAxis(double_t xmin, double_t ymin, double_t xmax, double_t ymax, if (angle == 0) textaxis->SetTextAlign(21); s = 3; } - std::cout << "Here first" << std::endl; + //std::cout << "Here first" << std::endl; textaxis->PaintLatex(fAxis->GetBinCenter(i), ymin + s*fAxis->GetLabelOffset()*(gPad->GetUymax()-gPad->GetUymin()), angle, @@ -753,14 +753,14 @@ void PaintAxis(double_t xmin, double_t ymin, double_t xmax, double_t ymax, textaxis->SetTextAlign(12); s = 3; } - std::cout << "Here second" << std::endl; + //std::cout << "Here second" << std::endl; textaxis->PaintLatex(xmin + s*fAxis->GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin()), fAxis->GetBinCenter(i), 0, textaxis->GetTextSize(), fAxis->GetBinLabel(i)); } else { - std::cout << "Here third" << std::endl; + //std::cout << "Here third" << std::endl; textaxis->PaintLatex(xmin - 3*fAxis->GetLabelOffset()*(gPad->GetUxmax()-gPad->GetUxmin()), ymin +(i-0.5)*(ymax-ymin)/nl, 0, @@ -1272,7 +1272,7 @@ L110: } typolabel = chtemp; typolabel.ReplaceAll("-", "#minus"); - std::cout << "New hope3" << std::endl; + //std::cout << "New hope3" << std::endl; textaxis->PaintLatex(gPad->GetX1() + xx*(gPad->GetX2() - gPad->GetX1()), gPad->GetY1() + yy*(gPad->GetY2() - gPad->GetY1()), 0, @@ -1436,7 +1436,7 @@ L110: if ((nbinin <= n1a) || (j == 1) || (j == nbinin) || ((nbinin > n1a) && (j%kmod == 0))) { - std::cout << "RADEKhura " << std::endl; + //std::cout << "RADEKhura " << std::endl; if (labelnumber == 0) { textaxis->PaintTextNDC(xx,yy,"1"); @@ -1512,7 +1512,7 @@ L110: } else { if (noExponent) { textaxis->PaintTextNDC(xx,yy,&label[first]); - std::cout << "RADEKhura nova3 PUSSSSAAAAAAAAAAAA " <<xx<<" "<<yy << std::endl; + //std::cout << "RADEKhura nova3 PUSSSSAAAAAAAAAAAA " <<xx<<" "<<yy << std::endl; TLatex *lat = new TLatex(xx, yy, &label[first]); CopyLatexStyleNDC(lat, textaxis); lat->Draw(); @@ -1530,8 +1530,8 @@ L110: //lat->SetTextColor(kBlue); //lat->DrawLatexNDC(xx, yy, typolabel.Data()); - std::cout << "MMMMMMMMMMMM rest : " << textaxis->GetTextAlign() << std::endl; - std::cout << "RADEKhura nova1 "<<xx<<" "<<yy << std::endl; + //std::cout << "MMMMMMMMMMMM rest : " << textaxis->GetTextAlign() << std::endl; + //std::cout << "RADEKhura nova1 "<<xx<<" "<<yy << std::endl; TLatex *lat = new TLatex(xx, yy, typolabel.Data()); CopyLatexStyleNDC(lat, textaxis); lat->Draw(); @@ -1755,8 +1755,8 @@ inline double RemoveOverlaps(TVirtualPad *pad, TAxis *ax, bool remFirst=true, bo if(!pad->GetLogx()) gAx->PaintAxis(pad->GetUxmin(), pad->GetUymin(), pad->GetUxmax(), pad->GetUymin(), valMin, valMax, ndiv, ""); else { - std::cout << "RADEKOUTPUT " << pow(10,pad->GetUxmin()) <<" "<< pow(10,pad->GetUxmax()) << std::endl; - std::cout << "RADEKOUTPUT " << valMin <<" "<< valMax << std::endl; + //std::cout << "RADEKOUTPUT " << pow(10,pad->GetUxmin()) <<" "<< pow(10,pad->GetUxmax()) << std::endl; + //std::cout << "RADEKOUTPUT " << valMin <<" "<< valMax << std::endl; //gPad->SetLogx(); //gAx->PaintAxis(pow(10,pad->GetUxmin()), pad->GetUymin(), pow(10,pad->GetUxmax()), pad->GetUymin(), valMin, valMax, ndiv, "G"); gAx->PaintAxis(pad->GetUxmin(), pad->GetUymin(), pad->GetUxmax(), pad->GetUymin(), valMin, valMax, ndiv, "G"); diff --git a/test.py b/test.py new file mode 100644 index 0000000..e20ead2 --- /dev/null +++ b/test.py @@ -0,0 +1,41 @@ +from ROOT import gStyle, TCanvas, TH1D, Form, gSystem +gSystem.Load('plottingHelper_C.so') +from ROOT import PlottingHelper as ph + + + +gStyle.SetOptStat(0) + +def vec(vv): + from ROOT import std + vvv = std.vector("double")() + for v in vv: + vvv.push_back(v) + return vvv + + +can = TCanvas("can", "") +ph.DividePad(vec([1,1,1,1,1]), vec([1,1,1])) +hh = [] +for i in range(5*3): + can.cd(i+1) + h = TH1D(""+str(i),";;", 10, -3, 3) + nEv = 1000 - i*40 + h.FillRandom("gaus", nEv); + h.Draw("hist e") + hh.append(h) + ph.SetFTO(vec([12]), vec([5]), vec([1.2, 2, 0.3, 4])) + if i == 5*3-1: ph.GetXaxis().SetTitle("x"); + if i == 0: ph.GetYaxis().SetTitle("y"); + + ph.GetYaxis().SetRangeUser(0, 300) + + ph.DrawLatexUp( -1, "n_{Ev} = "+str(nEv)); + + #Remove overlaps of both axes + #RemoveOverlaps(gPad, GetXaxis(), true, true); + #RemoveOverlaps(gPad, GetYaxis(), true, true); + +ph.DrawLatexUp(can.GetPad(1), can.GetPad(5), 2, "This is a testing grid in Python"); +can.SaveAs("testGridPy.pdf"); + -- GitLab