Hi Farah, In the example that I sent to you two days ago, the equations were written at coordinates specified in user/pad coordinates. It is up to you to place the text at the best place. Below, you will find an alternative solution, where the equations are written in normalized device coordinates (NDC) that are independent of the pad range. Rene Brun void gonly() { TH1F *h1 = new TH1F("h1","test1",100,-2,2); TF1 f1("f1","gaus",-2,2); f1->SetParameters(1,-0.5,1); h1->FillRandom("f1",10000); TH1F *h2 = new TH1F("h2","test2",100,-2,2); f1->SetParameters(1,0.5,0.3); h2->FillRandom("f1",3200); h1->Fit("gaus","0"); h2->Fit("gaus","0"); TF1 *fit1 = (TF1*)h1->GetFunction("gaus"); TF1 *fit2 = (TF1*)h2->GetFunction("gaus"); fit1->SetLineColor(kRed); fit2->SetLineColor(kBlue); fit1->Draw(); fit2->Draw("same"); char text[100]; sprintf(text,"f1 = %g*e^{#frac{x%g}{%g}}", fit1->GetParameter(0), fit1->GetParameter(1), fit1->GetParameter(2)); TLatex *l1 = new TLatex(0.15,0.3,text); l1->SetNDC(); l1->SetTextSize(0.04); l1->SetTextFont(72); l1->SetTextColor(kRed); l1->Draw(); sprintf(text,"f2 = %g*e^{#frac{x-%g}{%g}}", fit2->GetParameter(0), fit2->GetParameter(1), fit2->GetParameter(2)); TLatex *l2 = new TLatex(0.15,0.15,text); l2->SetNDC(); l2->SetTextSize(0.04); l2->SetTextFont(72); l2->SetTextColor(kBlue); l2->Draw(); } On Tue, 10 Dec 2002, Farahnaaz Nauyock wrote: > Hi ya, > > I need to plot my Gaussian function in a specific range. Hence I'm using > the option "0R". However the problem with using this fuction is that my > gaussian equations don't appear on the canvas. Can someone please tell me > what drawing option to use to fit my plot in a specific range and at the > same time manage to get those gaussian equations on the canvas? > > Cheers, > Farah >
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:23 MET