How to move/resize statistics box?

Hi,

how can I move and/or resize the statistics box?

Cheers,
Carsten

You can do this directly with the mouse.

To it it from C++, see
root.cern.ch/root/htmldoc/THistP … nter:Paint
and look at section “Statistics Display”

Rene

Hi Rene,

thanks for pointing me the the web page, it’s exactly what I needed.
Unfortunately my program crashes if I add the “TPaveStats” lines with a segmentation violation. I’m not sure why this is happening (using ROOT 4.00/08 ), and I’ve already tried several x start/end positions. I guess that it’s a stupid mistake on my side, but I just don’t get it. Any help is appreciated.

Cheers,
Carsten

...
TCanvas *c1 = new TCanvas("c1","c1",700,400); 
gr->Draw("AP z");

TPaveStats *st = (TPaveStats*)gr->FindObject("stats");
st->SetX1NDC(0.1); //new x start position
st->SetY1NDC(0.1); //new x end position
gr->Draw("AP z");
...

You can also try this:

{
   gStyle->SetStatX(0.4);
   gStyle->SetStatY(0.3);
   TH1F* h = new TH1F("h","h",100,-5,5);
   h->FillRandom("gaus");
   h->Draw();
}

Carsten,

The stats box is only generated when effectively painting the canvas.
You must trigger painting by calling
mycanvas.Update() just before getting the TPaveStats object.

Rene

Thanks, both suggestions are working fine!!

Carsten