Change of axis range


I’m wrking with a TH2F histogram, which I define very early where I do not exactly know where I’ve entries.
It often happens that the area where I’ve entries is quite small in comparision with the whole range of the histogram.

When I create Plots, I am just interested in the area with entries.
Is there an easy way to “automatic” set the range to this area?
I just found the workaround with projectX/projectY and look for the first bin which has an entry.
Here the idea for the x axis:

 TH2D histo(......
//Flill histo
// set range
 TH1D* hProj=histo.ProjectionX();
    int binxMin=0;
    int binxMax;
    delete hProj;

I think this is not a reallyh nice way…
Is there a nicer way to find the right axis range?


I do not think there is an automatic way to find the “no empty space” but simple loops along X and
Y axis will do the job. You can make a smalle generic function doing that.