If you have a TH1 and you store a function in it, say from a TH1::Fit call, the function’s fMaximum is seemingly ignored.
As an example (PyROOT code):
import ROOT h = ROOT.TH1D("h","h",10,0,10) h.FillRandom("gaus") h.Fit("gaus") print [f for f in h.GetListOfFunctions()] # Just to show the function is there. h.GetListOfFunctions().SetParameter(0,1e6)
At this point, if you update the gPad, the vertical scale is huge because it tries to accommodate the TF1’s values within the X range of the TH1.
The intuitive thing for a user to do is to try to use the TF1’s SetMaximum method to set it to something reasonable, but this does nothing. Something that does work (unintuitively) is to use the histogram’s SetMaximum method, which apparently restricts the TF1 if it is not the default value of -1111. This leads to some strange-looking calls:
This sets the Y range to one appropriate for viewing the histogram with the function on top if it happens to be in frame.
Why does TF1::SetMaximum not work here? Understand that GetMaximum and SetMaximum are not supposed to be symmetric (Get is a search/minimization), so there is no method for checking that the fMaximum member of the TF1 has been changed. I don’t know if fMaximum is ignored or if it just isn’t set.
I’d appreciate an explanation, but I’d mostly appreciate if the TF1’s SetMaximum method did the expected thing. I tested a TF1 not stored in a histogram, and it does obey SetMaximum.