Drawing TF1 fit function with error bands

Dear all,
I have an histogram that I fit with a 1-D function.
I would like to draw said fitting function with an option similar to “E3” for graphs.
Is there a way to do this?
I have been trying all the graphical options known to me and looking on tutorials and everything,
but so far nothing works, the end result is always the display of the fitting function as a line
(no error message either)…
I have also tried to initialise another function with the parameters computed by the fitting procedure, but still no success…
Any help is more than welcome…
Thanks a lot

root [4] hpx->SetFillColor(kRed);
root [5] hpx->Draw("E3")

thanks for the advice, this works for the points of the histogram.
I would like for the band to be on the fit function.
Substituting hpx (histogram) with the fitting function I obtain something that is not quite right… I cannot manage to keep the histogram drawn with option “pe” and the fitting function drawn with option Ex
Anyway, this is something minor for me, but it would be good to have such feature…

The way to decouple the histogram drawing option from the function drawing option would be:

root [1] hpx->Fit("gaus");
root [2] hpx->Draw("hist")
root [4] hpx->GetFunction("gaus")->Draw("E3 same");

But then the function should have errors … which does not seems the default

apparently when the fit function is drawn with “E3” option, the plotted error bands are obtained assuming a poissonian distribution for each point of the function itself. For this reason errors on the fit parameters are not taken into account and this is different from a proper calculation of a 95% confidence interval.


It would have been better to create a new post … this one is 4 years old ! …
May be @moneta can help.

To plot the confidence interval of a fitted function, see the tutorial


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.