Plotting difference between pseudo-data and fit on the same plot

I am trying to plot the pseudo-data minus the fit for a 5-parameter function. I have done this before with actual data, but for some reason, this time I am not getting a graph that shows the difference on the same canvas. I get the following warnings:
Warning in <TPad::ResizePad>: Inf/NaN propagated to the pad. Check drawn objects.
Warning in <TPad::ResizePad>: Comp_2 height changed from 0 to 10
I am very confused and any help would be greatly appreciated.
para_five_difference.cxx (2.5 KB)
_ROOT Version: 6.23/01

at line 53 you do a fit


from line 61 on you set params again:


so your fitted params are lost

1 Like

Thank you, it worked. Do you know how I could make it so that the axes are log-scaled?


for details see:

1 Like

Thank you again. Sorry to bother you again, but when I try to divide by the Bin error (line 81), I get the same problem as before. para_five_difference.cxx (2.5 KB)

your DiffHist (as it was before) represents the residuals
(bin_content - fitted_value).
Why do you divide the fitted_value by the bin_error?
In this way you cannot expect something centered around 0

in my last answer I overlooked one of your many “((((()))))”
real problem is that the bin_error can be 0 giving devide by 0 -> NaN
You must check for that.

1 Like

Thank you again! I just added an if statement in the for loop, and it seems to work.
para_five_difference.cxx (2.5 KB)