ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
hlabels2.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// 2-D histograms with alphanumeric labels.
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Rene Brun
9 
10 TCanvas *hlabels2()
11 {
12  const Int_t nx = 12;
13  const Int_t ny = 20;
14  const char *month[nx] = {"January","February","March","April","May",
15  "June","July","August","September","October","November",
16  "December"};
17  const char *people[ny] = {"Jean","Pierre","Marie","Odile","Sebastien",
18  "Fons","Rene","Nicolas","Xavier","Greg","Bjarne","Anton",
19  "Otto","Eddy","Peter","Pasha","Philippe","Suzanne","Jeff",
20  "Valery"};
21  TCanvas *c1 = new TCanvas("c1","demo bin labels",10,10,600,600);
22  c1->SetGrid();
23  c1->SetLeftMargin(0.15);
24  c1->SetBottomMargin(0.15);
25  TH2F *h = new TH2F("h","test",3,0,3,2,0,2);
27  h->SetStats(0);
28  gRandom->SetSeed();
29  for (Int_t i=0;i<15000;i++) {
30  Int_t rx = gRandom->Rndm()*nx;
31  Int_t ry = gRandom->Rndm()*ny;
32  h->Fill(people[ry],month[rx],1);
33  }
34  h->LabelsDeflate("X");
35  h->LabelsDeflate("Y");
36  h->LabelsOption("v");
37  h->Draw("text");
38 
39  TPaveText *pt = new TPaveText(0.6,0.85,0.98,0.98,"brNDC");
40  pt->SetFillColor(18);
41  pt->SetTextAlign(12);
42  pt->AddText("Use the axis Context Menu LabelsOption");
43  pt->AddText(" \"a\" to sort by alphabetic order");
44  pt->AddText(" \">\" to sort by decreasing values");
45  pt->AddText(" \"<\" to sort by increasing values");
46  pt->Draw();
47  return c1;
48 }
const int nx
Definition: kalman.C:16
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
virtual void LabelsOption(Option_t *option="h", Option_t *axis="X")
Set option(s) to draw axis with labels.
Definition: TH1.cxx:4901
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
Definition: TRandom.cxx:512
TCanvas * c1
Definition: legend1.C:2
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Add a new Text line to this pavetext at given coordinates.
Definition: TPaveText.cxx:160
int Int_t
Definition: RtypesCore.h:41
virtual void SetSeed(UInt_t seed=0)
Set the random generator seed.
Definition: TRandom.cxx:568
const int ny
Definition: kalman.C:17
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:326
virtual void SetTextAlign(Short_t align=11)
Definition: TAttText.h:55
virtual void SetBottomMargin(Float_t bottommargin)
Set Pad bottom margin in fraction of the pad height.
Definition: TAttPad.cxx:97
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
2-D histogram with a float per channel (see TH1 documentation)}
Definition: TH2.h:256
virtual void LabelsDeflate(Option_t *axis="X")
Reduce the number of bins for the axis passed in the option to the number of bins having a label...
Definition: TH1.cxx:4776
R__EXTERN TRandom * gRandom
Definition: TRandom.h:62
The Canvas class.
Definition: TCanvas.h:48
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:35
virtual UInt_t SetCanExtend(UInt_t extendBitMask)
make the histogram axes extendable / not extendable according to the bit mask returns the previous bi...
Definition: TH1.cxx:6211
Int_t Fill(Double_t)
Invalid Fill method.
Definition: TH2.cxx:287
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8320
virtual void SetLeftMargin(Float_t leftmargin)
Set Pad left margin in fraction of the pad width.
Definition: TAttPad.cxx:107