labels2.C

Go to the documentation of this file.
00001 //Setting alphanumeric labels 
00002 //Author: Rene Brun
00003 void labels2()
00004 {
00005    const Int_t nx = 12;
00006    const Int_t ny = 20;
00007    char *month[nx]  = {"January","February","March","April",
00008       "May","June","July","August","September","October",
00009       "November","December"};
00010    char *people[ny] = {"Jean","Pierre","Marie","Odile",
00011       "Sebastien","Fons","Rene","Nicolas","Xavier","Greg",
00012       "Bjarne","Anton","Otto","Eddy","Peter","Pasha",
00013       "Philippe","Suzanne","Jeff","Valery"};
00014    TCanvas *c1 = new TCanvas("c1","demo bin labels",
00015       10,10,800,800);
00016    c1->SetGrid();
00017    c1->SetLeftMargin(0.15);
00018    c1->SetBottomMargin(0.15);
00019    TH2F *h = new TH2F("h","test",nx,0,nx,ny,0,ny);
00020    for (Int_t i=0;i<5000;i++) {
00021       h->Fill(gRandom->Gaus(0.5*nx,0.2*nx), 
00022          gRandom->Gaus(0.5*ny,0.2*ny));
00023    }
00024    h->SetStats(0);
00025    for (i=1;i<=nx;i++) h->GetXaxis()->SetBinLabel(i,month[i-1]);
00026    for (i=1;i<=ny;i++) h->GetYaxis()->SetBinLabel(i,people[i-1]);
00027    h->Draw("text");
00028    
00029    TPaveText *pt = new TPaveText(0.6,0.85,0.98,0.98,"brNDC");
00030    pt->SetFillColor(18);
00031    pt->SetTextAlign(12);
00032    pt->AddText("Use the axis Context Menu LabelsOption");
00033    pt->AddText(" \"a\"   to sort by alphabetic order");
00034    pt->AddText(" \">\"   to sort by decreasing vakues");
00035    pt->AddText(" \"<\"   to sort by increasing vakues");
00036    pt->Draw();
00037 }

Generated on Tue Jul 5 15:44:22 2011 for ROOT_528-00b_version by  doxygen 1.5.1