Skip to content

[hist] in TTree::Draw, last bin should include vmax values #17689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions hist/hist/src/THLimitsFinder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -401,5 +401,12 @@ void THLimitsFinder::OptimizeLimits(Int_t nbins, Int_t &newbins, Double_t &xmin,
if (xmin +nbins*bw < umax) {nbins++; xmax = xmin +nbins*bw;}
if (xmin > umin) {nbins++; xmin = xmax -nbins*bw;}
}
else {
xmax = std::max(xmax + 1e-15*(xmax - xmin), std::nextafter(xmax,INFINITY));
// If we put the upper bin limit directly at xmax, then all values at xmax will go into the overflow and will be invisible.
// So shift it slightly to the right, by at least 1e-12 when hist_xlow=-1000, hist_xup=0 and nbins = 100.
// Otherwise, it still does not plot the max data it with the reproducer at https://root-forum.cern.ch/t/bug-or-feature-in-ttree-draw/62862
// due to the rounding in TAxis::FindBin line: bin = 1 + int (fNbins*(x-fXmin)/(fXmax-fXmin) );.
}
newbins = nbins;
}
Loading