Stat box options with using Divide

Hi,

I have the following problem: I have a canvas with several histograms that was created with Divide. The different histograms shall have different Stat options depending on wether there is a fit in it or not. I tried to change SetOptStat before drawing and after (to set it back) but then the wrong histogram has changed options.
I found that a similar problem was discussed last year but there the question was just to draw statistics or not which can be done by histo->SetStats(0). As the histogram does not have an option to specify the statistics format I do not knwo how to circumvent gStyle and get it right.

A snippet of my code looks like that:
gStyle->SetOptFit(0111);
gStyle->SetOptStat(11);

c0 = new TCanvas(“PlotEnsC”,“PlotEnsC”,ox,oy[0],parnames.size()wd,3ht);
c0->Divide(3,3,0.001,0.001);

c0->cd(ipad*npar+i+1);
tree->Draw(fitexpr.str().c_str(),sselection.str().c_str());

gStyle->SetOptStat(1111);
tree->Draw(errexpr.str().c_str(),sselection.str().c_str());
gStyle->SetOptStat(11);

tree->Draw(pullexpr.str().c_str(),sselection.str().c_str());

I would expect that the histogram coming from the second “Draw” has the changed stats but instead it is the first one! Also, the first plot does not contain fit info anymore although I did not change SetOptFit.
If you need the full code to reproduce the problem, please tell me.

Thanks in advance

Petra

To change individual stats box, get a pointer to the TPaveStats object and call the setter functions like SetOptStat, SetOptFit, eg

TPaveStats *s1 = (TPaveStats*)h1->GetListofFunctions()->FindObject("stats"); s1->SetOptStat(11111);
Rene

Hi Rene,

thanks for your help. Accessing the stat box directly works (if one calls canvas->Update() before). But somehow this shows strange behaviors. I’ll attach three pictures to this message to illustrate. The first one PlotEnsC_good.ps shows the behavior before these changes. As you can see in the middle row only the number of entries is given. As there is no fit in there I would like to show the histo mean and RMS in that cases. The second plot PlotEnsC_bad.jpg is a screenshot of the modified canvas. The stat boxes in the second row are modified correctly but somehow the stat boxex in the first row got wrong and the titles in the first and second row changed to something non-readable. If I save this canvas, I get the third plot PlotEnsC_save.ps. Here, the stat boxes and titles are fine. But the stat boxes have all the same sizes in contrast to the first plot, where the boxes with more entries were larger. That makes the entries in the first and second row hard to read. I tried several combinations of gPad->Modified(), gPad->Update() and canvas->Update() after modifying the stat boxes to get the screen picture right but did not succeed. Also, I do not understand why the sizes in the first and last row change with modifications in the second row!? Can you explain and help?

Thanks a lot!

Petra
PlotEnsC_bad.ps (186 KB)
PlotEnsC_save.ps (51.3 KB)
PlotEnsC_good.ps (52.3 KB)

FYI the file PlotEnsC_bad.ps is not a PostScript file. It is a binary one which can be seen with xv (on linux).

Oops, I am sorry. As I wrote in the text it is a jpeg file. Somehow the file extension got confused.