ROOT logo

From $ROOTSYS/tutorials/hist/hlabels1.C

// 1-D histograms with alphanumeric labels
// author; Rene Brun
void hlabels1()
{
   const Int_t nx = 20;
   char *people[nx] = {"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,900,500);
   c1->SetGrid();
   c1->SetTopMargin(0.15);
   TH1F *h = new TH1F("h","test",3,0,3);
   h->SetStats(0);
   h->SetFillColor(38);
   h->SetBit(TH1::kCanRebin);
   for (Int_t i=0;i<5000;i++) {
      Int_t r = gRandom->Rndm()*20;
      h->Fill(people[r],1);
   }
   h->LabelsDeflate();
   h->Draw();
   TPaveText *pt = new TPaveText(0.7,0.85,0.98,0.98,"brNDC");
   pt->SetFillColor(18);
   pt->SetTextAlign(12);
   pt->AddText("Use the axis Context Menu LabelsOption");
   pt->AddText(" \"a\"   to sort by alphabetic order");
   pt->AddText(" \">\"   to sort by decreasing values");
   pt->AddText(" \"<\"   to sort by increasing values");
   pt->Draw();
}
 hlabels1.C:1
 hlabels1.C:2
 hlabels1.C:3
 hlabels1.C:4
 hlabels1.C:5
 hlabels1.C:6
 hlabels1.C:7
 hlabels1.C:8
 hlabels1.C:9
 hlabels1.C:10
 hlabels1.C:11
 hlabels1.C:12
 hlabels1.C:13
 hlabels1.C:14
 hlabels1.C:15
 hlabels1.C:16
 hlabels1.C:17
 hlabels1.C:18
 hlabels1.C:19
 hlabels1.C:20
 hlabels1.C:21
 hlabels1.C:22
 hlabels1.C:23
 hlabels1.C:24
 hlabels1.C:25
 hlabels1.C:26
 hlabels1.C:27
 hlabels1.C:28
 hlabels1.C:29
 hlabels1.C:30
 hlabels1.C:31