Scaling y-axis for histograms with error bars and empty bins

Let assume I have histogram with N numbers of bins, but only k of the is filled with value and error bars, rest is untouched.

Now I am drawing it. The Y axis starts at 0, because of empty bins, upper range is calculated to fit histogram.

Now my question: what is the effective way to draw such histogram in the way that empty bins are not influencing y-scaling (do not force y-axis starting at 0).

One solutin is to use SetRangeUser and determine range by hand. How? Do I need to iterate bin-by-bin reading out content and error and calculating range by hand? is there some faster way? It must be somehow done for upper range of the histogram, but I could not dig into this in the code.

Using TGraph is also not an option since for unused points it also draw point at (0,0).

Rafał

Why don’t you do h->SetMinimum(yyy) ?

But I don’t know minimum, histograms are filled wit hdata, so I must find minimum by hand first.

Here:

root.cern.ch/root/htmldoc/TH1.h … GetMinimum

One can read:

I know this, but I have also error bars, and lowest bin content does not mean that lower boundar of the bin is also smallest. So I guess there is no straight way than just iterating and checking manually.

Maybe would be usefull to add drawing optin for TH1 which ignores empty bins (no data, no error).

Ok, A quick loop on the histogram errors and bins contain and errors will do the job. No need for a special option.