see example in the attachement
Rene Brun
> Stilianos Kesisoglou wrote:
>
> Hi,
>
> I have a histogram that I fit with two gaussians and at the end of the fit
> the stat box has all the parameters. I would like to color the parameters
> for the one gaussian with red and the others with blue.
>
> How can I do that?
>
> Thanks!
>
> Stelios.
void gaus2() {
TH1F *h = new TH1F("h","test",100,0,10);
TRandom r;
for (Int_t i=0;i<10000;i++) {
h->Fill(r.Gaus(4,0.5));
h->Fill(r.Gaus(6,1));
}
TF1 *f1 = new TF1("f1","[0]*TMath::Gaus(x,[1],[2])+[3]*TMath::Gaus(x,[4],[5])",0,10);
f1->SetParNames("C1","Mean1","Sigma1","C2","Mean2","Sigma2");
f1->SetParameters(1000,4,0.5,500,6,1);
gStyle->SetOptFit(1111);
TCanvas *c = new TCanvas;
h->Fit("f1");
c->Update();
TPaveStats *p = (TPaveStats*)h->GetListOfFunctions()->FindObject("stats");
h->GetListOfFunctions()->Remove(p);
h->SetStats(0);
p->GetLineWith("C1")->SetTextColor(kBlue);
p->GetLineWith("Mean1")->SetTextColor(kBlue);
p->GetLineWith("Sigma1")->SetTextColor(kBlue);
p->GetLineWith("C2")->SetTextColor(kRed);
p->GetLineWith("Mean2")->SetTextColor(kRed);
p->GetLineWith("Sigma2")->SetTextColor(kRed);
p->Draw();
}
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:08 MET