SetFitFormat does not apply to all numbers

Dear experts,

I have a histogram which I fit, and I draw the fit-box. I select options


which gives an odd result. Only the p0 mean value is shown in this format, while the error is shown as 0.0. See the attached image.

The fit-result in the terminal gives this info:

so as you see, I would like that the error shows up properly, and not just quoted as 0.0.

What could possibly be the reason for this behaviour? Could it be some conflicting settings in some other of my style-files I wonder, or is there an extra option that I missed?

I find that if I run my plotting script, but then do a fit from the gui fit-panel, then both the mean fit and the error is shown as I expect, with scientific notation on both.

Thanks a lot,

Can you provide a small macro reproducing this effect ?


you can run the attached python-file using the attached root-file as input.

At least on my machine this reproduces the problem.

Maiken (848 Bytes)
histos.root (4.25 KB)

I converted you macro to C++ (attached). It gives me the attached picture.
For me it looks fine. I am using ROOT 5.34 on Mac

plotter_forum.C (913 Bytes)

Thanks, yes, when I run with the .C file it works for me also. But I would prefer not to rewrite all my python scripts to C :slight_smile:

So is there some trick or good reason why this should not work in python with pyroot?

Aha, I notice that once I remove the Divide from the .py file I get the correct result. This is strange!


So it looks like a Python issue. I let a python expert answer.


no, as the two scripts are NOT the same. The .py makes a .png and the .C has a Divide commented out (as Maiken also pointed out). The .png is not relevant, but the .C does NOT work if the Divide is left in place, and conversely the .py gives the same result if the Divide is removed (i.e. an error printed with e-03 in place).

Note that the Divide is simply missing a cast in the .C: it needs a (TH1F*) cast added of the result of Get() in order to select the proper overload. Do that, and it will produce the result printing an error of ± 0.0.


Ok, thanks, so you confirm that they same problem occurs in the .C script and the .py script.

How then to go about solving the issue?

Thanks a lot,


dunno … not familiar with this code, and I don’t see any documentation for SetFitFormat(). However, toying around, it seems that this at least prints the error correctly:gStyle.SetFitFormat('2.3fe')both in .C and .py, and with or without divide.

However, what ‘fe’ means, I don’t know.


Great, ok. Well, good enough for me, it works here too. So let’s settle for that!
f=float (usually will just give typically 10.0?)
e=scientific notation (would usually give 1.0e1?)

so double up seems to help??