I have a TH1 histogram that I want to fit with a TF1 function. I would like to fit the function within a narrow range, and then draw it over a wider range. I tried the obvious things:
but I can’t find the magic combination that will fit in the narrow range from tincmin to tincmax, and then draw over the full 0 to 0.5 range. What am I missing?
sub1->Fit(finc1,"0","",tincmin,tincmax); //add 0 option, i.e. don't draw
// also you can use finc1 directly instead of via-name
sub1->Draw(); // reorder: first draw sub1
finc1->Draw("same"); // add "same"
In your code, a fitted function for the fit range gets added to the list of functions. Then you draw your fitted function in the whole range and immediately overwrite the plot with the histogram plus its added function.