Add an option to TH1 to "center" the bins

Hello, I did not find any option of the Draw method to “center” the bins. I mean that iI define an histo like that

And if I have only one value at X=5, I will get I bar starting from 5 and ending to 6. Is it possible to start the bin at 4.5 and end it to 5.5 (the center of the bar is at 5 and not at 5.5)?.
The only way I found is to define the histogram like that

I would appreciate if a Draw option can do that automatically.

Sorry if the option already exists but I did not find.

root [0] TH1I *h = new TH1I("h","h",10,0,10);
root [1] h->Fill(5)
root [2] h->SetFillColor(2)
root [3] h->SetBarOffset(-0.5)
root [4] h->Draw("b")
1 Like

Ah ! I did not catch what was the utility of the “b” option. Your solution is more general. Thank you.

The B option allows to plot several histo next to each other by shifting them (SetBarOffset). The bar width can be also defined for each histo.