Move stat box

hi!

I want to move the setoptfit-box because it covers parts of my graph. I tried

gStyle->SetOptFit();
fStatX=0.1;
fStatY=0.1;

but nothing changed. Any ideas?

1 Like

root.cern.ch/root/html/THistPainter.html#HP07

Jan

You can probably move it with your mouse. Try dragging the edges of the box.

Hi Ian! This works for the self-defined stat-box, but not for statoptfit, does it? my stat box doesn’t have a name or at least i don’t know it

Plus, i have TGraphErrors, no histograms. should have mentioned this earlier

I have 50 canvi, so a prefer a macro-solution…thanks anyway :slight_smile:

try this macro:{ gStyle->SetOptFit(); gROOT->Macro("$ROOTSYS/tutorials/graphs/gerrors.C"); ge = (TGraphErrors *)c1->GetListOfPrimitives()->FindObject("Graph"); ge->Fit("gaus"); c1->Modified(); c1->Update(); pt = (TPaveText *)c1->GetListOfPrimitives()->FindObject("title"); pt->SetX1NDC(0.4); pt->SetX2NDC(0.7); pt->SetY1NDC(0.15); pt->SetY2NDC(0.25); ps = (TPaveStats *)ge->GetListOfFunctions()->FindObject("stats"); ps->SetX1NDC(0.15); ps->SetX2NDC(0.55); c1->Modified(); c1->Update(); }Jan

1 Like

great, this works…thank you! :slight_smile:

Why don’t TGraph and TH1 and/or TF1 have a direct way to access their own stat box?

In general I think that looking for stuff with FindObject( a_default_name) is quite unclean and should be avoided. Is there a compelling reason not to give the user a GetStatBox() function?

[quote]Why don’t TGraph and TH1 and/or TF1 have a pointer to their own stat box?
[/quote]They have! The TPaveStats is attached to hist.GetListOfFunctions(). This is a TList and it can contain more than one object.

[quote]The problem is that all stat box are called “stat” by default and if you have more than one in a canvas it’s a mess (you have to remember to move them efore creating new ones).
[/quote]
Yes and I think we indicate quite well how to get more than one stat box (see also examples above).

You are contradicting yourself. Having one pointer only cannot work. With the current implementation you do not look via FindObject in the canvas, but in the histogram having one or more stats box.

Rene

1 Like