Skip to content

Commit 36900d4

Browse files
committed
add draw options fhideup and fhidelow
1 parent 541c83f commit 36900d4

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

graf2d/gpad/inc/TRatioPlot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ class TRatioPlot : public TPad {
5959
kHideUp = 1, ///< Hide the first label of the upper y axis when there is low space.
6060
kHideLow = 2, ///< Hide the last label of the lower y axis when there is low space.
6161
kNoHide = 3, ///< Do not hide labels when there is low space.
62+
kForceHideUp = 4, ///< Always hide the first label of the upper y axis
63+
kForceHideLow = 5 ///< Always hide the last label of the lower y axis
6264
};
6365

6466

graf2d/gpad/src/TRatioPlot.cxx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ TRatioPlot::TRatioPlot(TH1* h1, TH1* h2, Option_t *optH1, Option_t *optH2, Optio
252252

253253
}
254254

255+
255256
////////////////////////////////////////////////////////////////////////////////
256257
/// Constructor which accepts a `THStack` and a histogram. Converts the
257258
/// stack to a regular sum of its containing histograms for processing.
@@ -541,7 +542,9 @@ Float_t TRatioPlot::GetSeparationMargin()
541542
/// | ---------- | ------------------------------------------------------------ |
542543
/// | grid / nogrid | enable (default) or disable drawing of dashed lines on lower plot |
543544
/// | hideup | hides the first label of the upper axis if there is not enough space |
545+
/// | fhideup | always hides the first label of the upper axis |
544546
/// | hidelow | hides the last label of the lower axis if there is not enough space |
547+
/// | fhidelow | always hides the last label of the lower axis |
545548
/// | nohide | does not hide a label if there is not enough space |
546549
/// | noconfint | does not draw the confidence interval bands in the fit residual case |
547550
/// | confint | draws the confidence interval bands in the fit residual case (default) |
@@ -567,7 +570,11 @@ void TRatioPlot::Draw(Option_t *option)
567570
fShowConfidenceIntervals = kTRUE; // <- default
568571
}
569572

570-
if (drawOpt.Contains("hideup")) {
573+
if (drawOpt.Contains("fhideup")) {
574+
fHideLabelMode = TRatioPlot::HideLabelMode::kForceHideUp;
575+
} else if (drawOpt.Contains("fhidelow")) {
576+
fHideLabelMode = TRatioPlot::HideLabelMode::kForceHideLow;
577+
} else if (drawOpt.Contains("hideup")) {
571578
fHideLabelMode = TRatioPlot::HideLabelMode::kHideUp;
572579
} else if (drawOpt.Contains("hidelow")) {
573580
fHideLabelMode = TRatioPlot::HideLabelMode::kHideLow;
@@ -1304,9 +1311,16 @@ void TRatioPlot::CreateVisualAxes()
13041311
Double_t ticksize = fUpperGYaxis->GetTickSize()*ratio;
13051312
fLowerGYaxis->SetTickSize(ticksize);
13061313

1307-
// hide first label of upper y axis
13081314

1309-
if (GetSeparationMargin() < 0.025) {
1315+
if (fHideLabelMode == TRatioPlot::HideLabelMode::kForceHideUp) {
1316+
1317+
fUpperGYaxis->SetLabelAttributes(1, -1, 0);
1318+
1319+
} else if (fHideLabelMode == TRatioPlot::HideLabelMode::kForceHideLow) {
1320+
1321+
fLowerGYaxis->SetLabelAttributes(-1, -1, 0);
1322+
1323+
} else if (GetSeparationMargin() < 0.025) {
13101324

13111325
if (fHideLabelMode != TRatioPlot::HideLabelMode::kNoHide) {
13121326
if (fHideLabelMode == TRatioPlot::HideLabelMode::kHideUp) {

0 commit comments

Comments
 (0)