Histogram Draw Problem

Hi all,

I’m attaching an image of a set of histograms I’ve drawn. The 1D histograms are all TH1F, but this issue also occurs with TH1I. The issue I’m having problems with is that at the top of each bin there is a little “hook” that stands off from the bin. It makes the histograms very ugly to look at.

It’s not a particularly serious issue, as exporting the image to c1.jpg/png/etc, makes the hooks go away. However, when working through a long analysis, it does give me a headache; so I’d like to fix it.

System Specs:
OS: Ubuntu 13.04
Root Build: 5.34/09

I’ve done nothing special besides define the histograms, fill them with data, and then issue a hist.Draw().

Any idea on what might cause such an issue?


I do not see what you are talking about on the plot you posted.

The issue I’m having problems with is that at the top of each bin there is a little “hook” that stands off from the bin.

I do not see what you are talking about on the plot you posted.[/quote]
I think he is talking about the pixel on the right which is displayed next to the top of each bin.

Ah ok I see … my old eyes did not catch those dots at a first glance.

Can you post a small macro reproducing this effect ?


There really isn’t a macro specfic thing done to reproduce the effect. If one fills a histogram with data and then draws it, this always happens with my root install.

If you’d like, I can pass along the basic root tree that contains the data plotted here. But there is nothing code specific that causes the effect. My thought is that it has to do with the drawing method root is using (openGL is standard?). However, I’ve not found a way to test that theory. Was hoping something like this had been seen before.

This has been happening both with this install of Root and with a previous install (v5.29).


Can you send me the histogram you plot in that case ? my guess is that it can be connected to the number of bins.

Here are the files I’m using to produce that picture.

If you place them both in the same folder, then in root:

.x pl_TBGO.C

it should access the root tree and plot the histograms in a canvas.

out57.root (132 KB)
pl_TBGO.C (350 Bytes)

I think you should attach directly the histograms that you showed in your first post (not the code to generate them).
To do it, you juste have to save your canvas in .C and/or .root. And send here these files.

I think it would be better because I runned your pl_TBGO.C and I did not get the “hooks” on my histograms.

Yes please, as it is a graphics issue we do not need the whole analysis macro.

Apologies, didn’t realize that was possible.

Here is the file as a .root file.

histoHooks.root (144 KB)

It looks ok for me. It must be something specific to your machine. Problem with X11 ?
with the screen definition ?
I am on Mac

I have had previous problems running an analyzer through Root due to X11. It (only sometimes… maybe 15% of the time) crashes with the error:

Error in : fatal X11 error (connection to server lost?!)
**** Save data and exit application ****

To be honest, I’m not well-versed enough in Root to know what that means; but since it was only crashing sometimes I was able to go past it. I tried a Root reinstall and the issue was not resolved.

I do not think this is related. What we can see on your screen dump are small glitches because of very tiny lines at the top of each bin. Seems to me it is because your screen is not precise enough or because your version of X11 has some precisions problems. I guess you see these glitches only with very small bins ? with wider be it should be fine… right ?

Correct. If I rebin to larger bins the glitch goes away. Even if I just zoom in so that the bins are larger on the screen; the problem goes away.

A suggestion: do you have the latest X11 for Ubuntu ?

It should be. This is a fresh install of Ubuntu 13.04 that I just ran the full upgrade and update for. I will attempt to update it.

Thanks for your help and time. Since this is not a Root specific issue (though, I only see things like this in Root, despite using a few other histogramming utilities, which is odd), I will attempt to find an answer regarding the Ubuntu problem.