Parameters are not displayed in statbox

Dear all,

i’ve fitted two horizontal lines in different domains to my measurements-results. Now I have the problem that I wish the statbox to display the fit parameters for both lines, but it only displays the parameters of one.

[code] TF1 *g1 = new TF1(“g1”,“pol0”,0.0E-008,2.5E-008);
TF1 *g2 = new TF1(“g2”,“pol0”,2.5E-008,5.1E-008);

	graph1 -> Fit(g1,"R");
	graph1 -> Fit(g2,"R+");

	gStyle->SetOptFit(0012); 
	graph1 -> Draw("AP");

[/code]

Can you post a small running macro reproducing this problem ?

Sorry I thought one parameter was missing in that stat box, but in fact you are doing 2 fits and you want to plot the 2 stat boxes. You should use the option SAMES as explained here:
root.cern.ch/root/html/THistPainter.html#HP060

Here it is:

[code]//Root-Klassen
#include <TROOT.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TMath.h>
#include <TF1.h>
#include <TGraph.h>
#include <TAxis.h>
#include <TMatrixD.h>
#include <TVirtualFitter.h>

void kante1(){
gROOT->Reset();

TGraph *graph1 = new TGraph();
 TH1D *hist = new TH1D("hist", "Höhenverteilung", 30, 0., 2.);
int zeile = 0;

double data[20] = {0,0,0,0,0,0,0,0,0,0, -1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009};
	
	while(zeile<20){	
		graph1 -> SetPoint(zeile,zeile*1.0E-009,data[zeile]);

		zeile++;
	}
	//EOF-Fehler korrigieren:


TCanvas *c1 = new TCanvas();

graph1 -> SetMarkerStyle(20);
graph1 -> SetMarkerSize(2);
TF1 *g1 = new TF1(“g1”,“pol0”,0.0E-008,0.9E-008);
TF1 *g2 = new TF1(“g2”,“pol0”,1.0E-008,2.0E-008);

	graph1 -> Fit(g1,"R");
	graph1 -> Fit(g2,"R+");

	gStyle->SetOptFit(0012); 
	graph1 -> Draw("AP");

}[/code]

Try this:

{
   TCanvas *c1 = new TCanvas;
   TGraph *graph1 = new TGraph();
   TH1D *hist = new TH1D("hist", "Höhenverteilung", 30, 0., 2.);
   Int_t i = 0;

   Double_t data[20] = {0,0,0,0,0,0,0,0,0,0, -1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009,-1.0E-009};

   while(i<20){
      graph1 -> SetPoint(i,i*1.0E-009,data[i]);
      i++;
   }

   TCanvas *c1 = new TCanvas();
   graph1 -> SetMarkerStyle(20);
   graph1 -> SetMarkerSize(2);
   TF1 *g1 = new TF1("g1","pol0",0.0E-008,0.9E-008);
   TF1 *g2 = new TF1("g2","pol0",1.0E-008,2.0E-008);

   TFitResultPtr r1 = graph1 -> Fit(g1,"RS");
   TFitResultPtr r2 = graph1 -> Fit(g1,"RS+");

   gStyle->SetOptFit(0);
   graph1 -> Draw("AP");
   c1->Update();
   TPaveText *pt = new TPaveText(1.240187e-08,-2.552966e-10,
                                 1.957123e-08,4.661017e-11,"br");

   pt->AddText(Form("First range %g #pm %g",r1->Parameter(0),r1->ParError(0)));
   pt->AddText(Form("2nd   range %g #pm %g",r2->Parameter(0),r1->ParError(0)));
   pt->Draw();
}

Thank you. Now it works fine.