How can I take a TH1 with variable bin width and make those bins equal width when plotting?

It’s much easier to just show you what I want:

Here we have a TH1F with variable bin widths (0, 5, 10, 15, 20, 30, 40, 50, 70, 100, 200, 1500), but each bin is given the same width when the plot is drawn. How is this done?

Thanks!

What you see is not the bins: it is the axis labels along the x axis it does not match the bins.

I’ve edited my original post to show how the bins match the ticks on the x-axis. Any idea how to achieve this?

Ok I see you got a plot already with what you are requesting ? isn’t it ?

Do you have the macro generating this plot ?

I guess (if it was generated with ROOT) the histograms plotted on top are normal ones with fixed bin size and the bottom axis was modified with ChangeLabel.

I don’t have the macro that generated this plot, I just saw it and wanted to replicate this style, but couldn’t figure out how it was done.

So the way to do this in ROOT is to sort of “fake it” by taking my original histogram and copying the bin values to a new histogram (where the bins may have the wrong x-values but are at least fixed width) and then changing the x-axis labels to fix the incorrect values? I see how that would work.

Is there no “proper” way to do this in the original histogram? If not I’ll try the above method.

I guess that’s the way it was done in that macro.

Okay, seems simple enough but creative. Thanks for the help!

Marked as solution.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.