Centring Bin number

I am using root_v6.14.06. How can we centralize no of bin as given in attached figure?
mul

{
  Int_t n = 11;
  TH1D *h = new TH1D("h", ";Jet multiplicity;Normalized to 1", n, 0., n);
  TAxis *xaxis = h->GetXaxis();
  xaxis->SetNdivisions(n, kFALSE); xaxis->CenterLabels(kTRUE);
  h->SetStats(kFALSE);
  // h->SetMaximum(0.62);
  h->Draw();
}

I have below mentioned histogram. In this, I want to set zero at 0.5 location. How can I move 0 to 0.5 location?

On this plot 0.5 is not the center of a level 1 division. CenterLabels will center the labels in the middle of the level 1 divisions. You will need to increase the number of divisions such as 0.5 becomes the centre of a level 1 division .

Try my example macro with: Int_t n = 12;

Yes I have tried with 12. And above histogram is plotted with (12,0,12).
I want to draw twelve bins with naming 0 to 12. Here just even numbers appearing.

Your plot (in your previous post) does not come from my macro. Try my macro as is, without any modifications (except setting n = 12).

I am using this macro in research. Kindly suggest me how can we make your suggested changes in it?
ZHHjetmul.C (2.7 KB)

It seems to me that you can first run my macro (it will create and draw the “frame”) and then run your macro (it will draw all your histograms using “hist same”).

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