Skip to content

Commit 74f1487

Browse files
committed
Chanhe calculation of Y range in log scale
1 parent 2d68e1f commit 74f1487

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

modules/gpad/TFramePainter.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ class TFramePainter extends ObjectPainter {
18071807
umax = pad[`fU${name}max`],
18081808
eps = 1e-7;
18091809

1810-
if (name === 'x') {
1810+
if (name === 'x') {
18111811
if ((Math.abs(pad.fX1) > eps) || (Math.abs(pad.fX2 - 1) > eps)) {
18121812
const dx = pad.fX2 - pad.fX1;
18131813
umin = pad.fX1 + dx*pad.fLeftMargin;
@@ -1904,6 +1904,9 @@ class TFramePainter extends ObjectPainter {
19041904
if (opts.ndim > 1) this.applyAxisZoom('y');
19051905
if (opts.ndim > 2) this.applyAxisZoom('z');
19061906

1907+
// TODO: extraction of PAD ranges must be done much earlier in hist painter
1908+
// normally histogram MUST set this ranges
1909+
// to be fixed after 7.6.0 release
19071910
if (opts.check_pad_range === 'pad_range') {
19081911
const canp = this.getCanvPainter();
19091912
// ignore range set in the online canvas
@@ -1960,7 +1963,7 @@ class TFramePainter extends ObjectPainter {
19601963
noexp_changed: this.y_noexp_changed,
19611964
symlog: this.swap_xy ? opts.symlog_x : opts.symlog_y,
19621965
logcheckmin: (opts.ndim < 2) || this.swap_xy,
1963-
log_min_nz: opts.ymin_nz && (opts.ymin_nz < this.ymax) ? 0.9*opts.ymin_nz : 0,
1966+
log_min_nz: opts.ymin_nz && (opts.ymin_nz <= this.ymax) ? 0.5*opts.ymin_nz : 0,
19641967
logminfactor: logminfactorY });
19651968

19661969
this.y_handle.assignFrameMembers(this, 'y');

modules/hist2d/TH1Painter.mjs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class TH1Painter extends THistPainter {
9090
this.hmin = hmin;
9191
this.hmax = hmax;
9292

93-
this.ymin_nz = hmin_nz; // value can be used to show optimal log scale
93+
// this.ymin_nz = hmin_nz; // value can be used to show optimal log scale
9494

9595
if ((this.nbinsx === 0) || ((Math.abs(hmin) < 1e-300) && (Math.abs(hmax) < 1e-300)))
9696
this.draw_content = false;
@@ -107,10 +107,16 @@ class TH1Painter extends THistPainter {
107107
this.ymin = 0; this.ymax = hmin * 2;
108108
}
109109
} else {
110-
const dy = (hmax - hmin) * gStyle.fHistTopMargin;
111-
this.ymin = hmin - dy;
112-
if ((this.ymin < 0) && (hmin >= 0)) this.ymin = 0;
113-
this.ymax = hmax + dy;
110+
const pad = this.getPadPainter()?.getRootPad(),
111+
pad_logy = (this.options.BarStyle >= 20) ? pad.fLogx : (pad?.fLogv ?? pad?.fLogy);
112+
if (pad_logy) {
113+
this.ymin = (hmin_nz || hmin) * 0.5;
114+
this.ymax = hmax*2*(0.9/0.95);
115+
} else {
116+
this.ymin = hmin - (hmax - hmin) * gStyle.fHistTopMargin;
117+
if ((this.ymin < 0) && (hmin >= 0)) this.ymin = 0;
118+
this.ymax = hmax + (hmax - this.ymin) * gStyle.fHistTopMargin;
119+
}
114120
}
115121
}
116122

0 commit comments

Comments
 (0)