00001
00002
00003 void labels1()
00004 {
00005 const Int_t nx = 20;
00006 char *people[nx] = {"Jean","Pierre","Marie","Odile",
00007 "Sebastien","Fons","Rene","Nicolas","Xavier","Greg",
00008 "Bjarne","Anton","Otto","Eddy","Peter","Pasha",
00009 "Philippe","Suzanne","Jeff","Valery"};
00010 TCanvas *c1 = new TCanvas("c1","demo bin labels",
00011 10,10,900,500);
00012 c1->SetGrid();
00013 c1->SetBottomMargin(0.15);
00014 TH1F *h = new TH1F("h","test",nx,0,nx);
00015 h->SetFillColor(38);
00016 for (Int_t i=0;i<5000;i++) {
00017 h->Fill(gRandom->Gaus(0.5*nx,0.2*nx));
00018 }
00019 h->SetStats(0);
00020 for (i=1;i<=nx;i++) {
00021 h->GetXaxis()->SetBinLabel(i,people[i-1]);
00022 }
00023 h->Draw();
00024 TPaveText *pt = new TPaveText(0.6,0.7,0.98,0.98,"brNDC");
00025 pt->SetFillColor(18);
00026 pt->SetTextAlign(12);
00027 pt->AddText("Use the axis Context Menu LabelsOption");
00028 pt->AddText(" \"a\" to sort by alphabetic order");
00029 pt->AddText(" \">\" to sort by decreasing values");
00030 pt->AddText(" \"<\" to sort by increasing values");
00031 pt->Draw();
00032 }