Draw fit in larger range

Hello,

I would like to draw the result of a fit on a larger range (rangeA, rangeB) than the one used for fitting (limit_a, limit_b). I wrote following code but doesn’t work:

TF1 *gauss_fit = new TF1("gauss_fit","gaus",rangeA, rangeB);
gauss_fit->SetRange(limit_a,limit_b);
gauss_fit->SetParameter(0,0);
gauss_fit->SetParameter(1,0);
gauss_fit->SetParameter(2,0);
hist->Fit("gauss_fit","Q","",limit_a,limit_b); // use option "B" to fix parameters
mean = gauss_fit->GetParameter(1); 
sigma = gauss_fit->GetParameter(2);
hist->SetName(fitname);
hist->Write(fitname);

I tried to specify gauss_fit->SetRange(rangeA,rangeB) and gauss->Draw() before writing but didn’t change. The TF1 is always drawn on the fitting range.

Thanks,
Nicolas

SetRange seems fine on TF1:

root [0] TF1 *f = new TF1("f","x",-3,3)
root [1] f->Draw()
root [2] f->SetRange(-10,10)
root [3] gPad->Modified(); gPad->Update()

After “hist->Fit(…);”, try: ((TF1 *)(hist->GetListOfFunctions()->FindObject("gauss_fit")))->SetRange(new_limit_a, new_limit_b);