How to remove the empty bin from TH1D histogram

I want to remove some certain bins from my TH1D histogram, if there are any easy way to do it?

Hi,
I don’t really understand, what you want to do. Do you mean removing like “cutting” right and left from the empty bin and “gluing” the histogram together? This would lead do an non-continuous x-axis and I think this is not supported by ROOT at all. Additionally this is probably not what you really want.

Cheers, Jörgen.

Hi,

Joergen is correct. If you really need it you can create a new histogram will the right number of bins, set bin labels to the filled bins’ positions, and set their bin contents by hand from the original histogram.

Cheers, Axel.

[quote=“jsamson”]Hi,
I don’t really understand, what you want to do. Do you mean removing like “cutting” right and left from the empty bin and “gluing” the histogram together? This would lead do an non-continuous x-axis and I think this is not supported by ROOT at all. Additionally this is probably not what you really want.

Cheers, Jörgen.[/quote]

This is exactly what I want to use. (I am not the original author of this poster) Could the developers add this option in the next version?

Right now there is only one complicated way to do this:

However, the plot made by this code is pretty good.

Cheers,
Jinzhong

The post you are referring to produces a broken Y axis. This is a purely graphics example. The data in this example are plotted using graphs. Graphs are not binned.