void BinLabels() { const Int_t nx = 12; const Int_t ny = 20; char *months[nx] = {"January","February","March","April","May","June","July", "August","September","October","November","December"}; char *people[ny] = {"Jean","Pierre","Marie","Odile","Sebastien","Fons","Rene", "Nicolas","Xavier","Greg","Bjarne","Anton","Otto","Eddy","Peter","Pasha", "Philippe","Suzanne","Jeff","Valery"}; TCanvas *c1 = new TCanvas("c1","demo bin labels",10,10,800,800); c1->SetGrid(); c1->SetLeftMargin(0.15); c1->SetBottomMargin(0.15); TH2F *h = new TH2F("h","test",nx,0,nx,ny,0,ny); for (Int_t i=0;i<5000;i++) { h->Fill(gRandom->Gaus(0.5*nx,0.2*nx), gRandom->Gaus(0.5*ny,0.2*ny)); } h->SetStats(0); h->GetXaxis()->SetLabelOffset(99); h->GetXaxis()->SetNdivisions(14); h->GetYaxis()->SetNdivisions(20); h->GetYaxis()->SetLabelOffset(99); h->Draw("text"); // draw labels along X Float_t x, y; y = gPad->GetUymin() - 0.2*h->GetYaxis()->GetBinWidth(1); TText t; t.SetTextSize(0.02); t.SetTextAlign(23); char xv[10]; for (i=0;iGetXaxis()->GetBinCenter(i+1); sprintf(xv,"%.1f",x); t.DrawText(x,y,xv); } // draw labels along y x = gPad->GetUxmin() - 0.1*h->GetXaxis()->GetBinWidth(1); t.SetTextAlign(32); for (i=0;iGetYaxis()->GetBinCenter(i+1); t.DrawText(x,y,people[i]); } }