I have been using root (and before that paw/hbook) for many years.
Today I run into an “unbelievable” problem.
On my Mac, when I Draw a histogram with option “e” for error bars, it decides to plot the error bars for each bin at the bins upper boundary. Hence, visible it looks as if the bins are shifted up by half a bin width. I tested with the same root version on lxplus, but here things are normal.
So, I reinstalled root on my Mac and went from root-6.20.00 to root-6.24.00 but with the same result.
On my Mac, my plot looks like this when Drawn with both option “hist e”.
That is what I feared.
So what on Earth can be wrong with my Mac, I wonder.
As I said, it made no difference to update the root version.
What else could I update?
It is really very annoying (and a unbelievable feature) not to be able to make plots with error bars.
Best,
-Mogens
Your result looks precisely as it should!
The problem is that on my Mac, bins are shifted upwards with half a bin-width when plotting with
error bars, as seen here:
You see this most clearly if you plot with the “hist e” option as I have done in the first plots in this thread. The hist option plots the bins where they should be. The “e” option shifts the bins up by half a bin-width.
As I wrote, this happens on my Mac, and not on lxplus, say. And not on your computer either.
So, something must be wrong with my Mac. But which kind of feature (on my Mac) could possibly make bins appear in the wrong position when plotting with error bars? Very mysterious.
My computer is a Mac too and I am running the latest ROOT version. Are you sure you are running the macro simple.C you posted ? (it seems you are running a very recent ROOT version so it should the same as what I get.)
That is interesting, I think I found my problem.
Since many, many years I have had in my rootlogon.C the following section
// Line widths
gStyle->SetBarWidth(2);
gStyle->SetLineWidth(2);
gStyle->SetFuncWidth(2);
gStyle->SetFrameLineWidth(2);
gStyle->SetHistLineWidth(2);
Now, it turns out that it is the gStyle->SetBarWidth(2) call, which creates the problem. The interesting point is that I can control completely how many half-bins I want the shift to be by adjusting the argument to that call. From a few trials the relation goes
To me, it is a bug if “SetBarWidth” modifies the “bar offset” (without any explicit call to “SetBarOffset”).
In the example in the previous post, in order fo fix the bug created by “exp->SetBarWidth(0.2);”, one needs to take a counteraction “exp->SetBarOffset(0.6);”.