diff --git a/RemoveOverlaps.h b/RemoveOverlaps.h index b9bd8993d8b4155ab9644e812d19ea083f31fe86..e12a67f41b17d16b3a1946ebc77d36377325e097 100644 --- a/RemoveOverlaps.h +++ b/RemoveOverlaps.h @@ -1691,7 +1691,7 @@ L210: -inline double RemoveOverlaps(TVirtualPad *pad, TAxis *ax, bool remFirst=true, bool remLast=true, bool isVisual = false) +inline double RemoveOverlaps(TVirtualPad *pad, TAxis *ax, vector<TString> excluded = {}, bool remFirst=true, bool remLast=true, bool isVisual = false) { //std::cout << "Helenka " << ax->GetName() << std::endl; pad->cd(); @@ -1789,10 +1789,22 @@ inline double RemoveOverlaps(TVirtualPad *pad, TAxis *ax, bool remFirst=true, bo } //std::cout << "Marketka "<<isX<<" "<<i<<" "<< myX1 <<" "<< myX2 <<" : "<< myY1<<" "<<myY2<< std::endl; - bool isOutside = (isX && ((remFirst && myX1 < 0) || (remLast && myX2 > 1))) || + bool isRemoved = (isX && ((remFirst && myX1 < 0) || (remLast && myX2 > 1))) || (!isX && ((remFirst && myY1 < 0) || (remLast && myY2 > 1) )); - if(isOutside) { + //removing labels by names + TString name = gAx->recsNDC[i].lat->GetTitle(); + name.ReplaceAll("#minus", "-"); + name.ReplaceAll("#times", " "); + name.ReplaceAll("{", ""); + name.ReplaceAll("}", ""); + + cout << "Helenka " << name << endl; + if(find(excluded.begin(), excluded.end(), name) != excluded.end()) { + isRemoved = true; + } + + if(isRemoved) { //ax->ChangeLabel(i+1, -1, 0); if(gAx->recsNDC[i].lat) li->Remove(gAx->recsNDC[i].lat); if(gAx->recsNDC[i].tex) li->Remove(gAx->recsNDC[i].tex); diff --git a/test.C b/test.C index c13fe7a15bb5c6e4f81dbfa91511b5a879b14985..5bac5f98d1b0b707626bb3ecf933cbf3c5a95ee3 100644 --- a/test.C +++ b/test.C @@ -29,8 +29,8 @@ void test() GetYaxis()->SetRangeUser(0, 300); DrawLatexUp( -1, Form("n_{Ev} = %d", nEv)); //Remove overlaps of both axes - RemoveOverlaps(gPad, GetXaxis(), true, true); - RemoveOverlaps(gPad, GetYaxis(), true, true); + RemoveOverlaps(gPad, GetXaxis(), {"-1", "2", "3"}, true, true); + RemoveOverlaps(gPad, GetYaxis(), {"150", "200"}, true, true); } DrawLatexUp(can->GetPad(1), can->GetPad(5), 2, "This is a testing grid"); diff --git a/test.py b/test.py index e20ead2bc571b1d7519a6e4b8ea40478d93ef1f4..3ced3f34a308ddd98d78063fba0d484cffd764ef 100644 --- a/test.py +++ b/test.py @@ -33,8 +33,8 @@ for i in range(5*3): ph.DrawLatexUp( -1, "n_{Ev} = "+str(nEv)); #Remove overlaps of both axes - #RemoveOverlaps(gPad, GetXaxis(), true, true); - #RemoveOverlaps(gPad, GetYaxis(), true, true); + #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"); diff --git a/test2.C b/test2.C index 92f7552e87b2995b214a3ccaa73106332d2212a6..1aa7e0380d30e2a02d163fd085124c0256df8d7a 100644 --- a/test2.C +++ b/test2.C @@ -27,7 +27,7 @@ void test2() } h->Draw("hist e"); GetXaxis()->SetMoreLogLabels(); - GetXaxis()->SetNoExponent(); + //GetXaxis()->SetNoExponent(); @@ -42,8 +42,8 @@ void test2() if(i%5 != 0 ) GetYaxis()->SetLabelSize(0.001); if(i < 10 ) GetXaxis()->SetLabelSize(0.001); - RemoveOverlaps(gPad, GetXaxis(), true, true); - RemoveOverlaps(gPad, GetYaxis(), true, true); + RemoveOverlaps(gPad, GetXaxis(), {"10^3"}, true, true); + RemoveOverlaps(gPad, GetYaxis(), {}, true, true); } DrawLatexUp(can->GetPad(1), can->GetPad(5), 2, "This is a testing grid");