Re: Multiple stat boxes for multiple TF1s in a single histogram

From: Rene Brun <>
Date: Thu, 16 Mar 2006 09:01:30 +0100 (MET)

Hi Chris,

There is only one "stats" box per histogram. To achieve what you want see example below.

Rene Brun

void fitmany() {

    TCanvas *c1 = new TCanvas;
    TH1F *h = new TH1F("h","test",100,-3,3);     h->FillRandom("gaus",50000);
    TH1F *hf1 = (TH1F*)h->Clone("hf1");
    TH1F *hf2 = (TH1F*)h->Clone("hf2");
    hf2->Fit("gaus","","sames",-0.8,0.8);     hf2->GetFunction("gaus")->SetLineColor(kRed);     c1->Update(); //to force the generation of the stats box     TPaveStats *p2 = (TPaveStats*)hf2->FindObject("stats");



On Wed, 15 Mar
2006, Chris
Schilling wrote:

> Hi,
> I am fitting a TH1 with multiple functions (using the '+') option. Then I
> store the histogram in a root file.
> I know how to access the various functions in the TH1, but I wonder how to
> get the fit boxes belonging to each TF1 and plotting them on the same Canvas.
> Currently the fit box for the first fit in the list of functions is
> displayed, even though that is not necessarily the function I am drawing. I
> would like to know how to draw the fit box corresponding to the function that
> I am drawing.
> Thanks for the advice
> Chris
Received on Thu Mar 16 2006 - 09:01:37 MET

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:57 MET