Automatic side-by-side stats boxes for THStack?

Hi, I am wondering if there is an easy way to use a THStack drawn with “nostack” with a non-zero SetOptStat value, such that it draws the stats boxes of the contained histograms side-by-side or tiled somehow so that they are all visible. All the examples I’ve seen just manually set the coordinates of the stats boxes, which seems rather tedious and prone to problems if you ever need to change anything (like the canvas size or font size or something).

Even if it’s not in the standard methods, someone out there must have written such a thing for themselves. Can such a person share their code?

Jean-François

I’ll see if something more automatic can be done.

By default le stats are not drawn like in the following example.
Do you have an example which draw the stats ?

{
   TH1F * h1 = new TH1F("h1", "h1", 100, -3., 3.);
   TH1F * h2 = new TH1F("h2", "h2", 100, -3., 3.);

   h1->FillRandom("gaus", 5000);
   h2->FillRandom("gaus", 4000);

   THStack * hs = new THStack("hs", "");
   hs->Add(h1);
   hs->Add(h2);
   hs->Draw("nostack");
}

I have written a set of handy functions which illustrate what I would like to accomplish with a new drawing option for THStack. The code is attached to this post.

My code only has standalone functions, but these could be turned into THStack methods. My code has comments explaining what the functions do, and the last function “DemonstrateStats” is more meant to be copy-and-pasted into the interpreter or read as an example of what a user can do with the functions.

I probably have violated a few ROOT coding styles/guidelines, but hopefully this will not detract from my overall point: a useful THStack draw option that draws the stat boxes of the contained histograms in such a way that they are all visible on the canvas.

Jean-François
tileStats.C (5.44 KB)

Thanks. I see what you are talking about now.
But I do not think we can encapsulate this code in a method. In particular I do not like the idea of generating the stats by drawing the histogram in some hidden canvas. I have added a Jira entry with this request:
sft.its.cern.ch/jira/browse/ROOT-6343