ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
hlabels1.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// 1-D histograms with alphanumeric labels
4 ///
5 /// \macro_image
6 /// \macro_code
7 ///
8 /// \author Rene Brun
9 
10 TCanvas *hlabels1()
11 {
12  const Int_t nx = 20;
13  const char *people[nx] = {"Jean","Pierre","Marie","Odile","Sebastien",
14  "Fons","Rene","Nicolas","Xavier","Greg","Bjarne","Anton","Otto",
15  "Eddy","Peter","Pasha","Philippe","Suzanne","Jeff","Valery"};
16  TCanvas *c1 = new TCanvas("c1","demo bin labels",10,10,900,500);
17  c1->SetGrid();
18  c1->SetTopMargin(0.15);
19  TH1F *h = new TH1F("h","test",3,0,3);
20  h->SetStats(0);
21  h->SetFillColor(38);
23  for (Int_t i=0;i<5000;i++) {
24  Int_t r = gRandom->Rndm()*20;
25  h->Fill(people[r],1);
26  }
27  h->LabelsDeflate();
28  h->Draw();
29  TPaveText *pt = new TPaveText(0.7,0.85,0.98,0.98,"brNDC");
30  pt->SetFillColor(18);
31  pt->SetTextAlign(12);
32  pt->AddText("Use the axis Context Menu LabelsOption");
33  pt->AddText(" \"a\" to sort by alphabetic order");
34  pt->AddText(" \">\" to sort by decreasing values");
35  pt->AddText(" \"<\" to sort by increasing values");
36  pt->Draw();
37  return c1;
38 }
const int nx
Definition: kalman.C:16
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3159
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
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
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:570
int Int_t
Definition: RtypesCore.h:41
virtual void SetTopMargin(Float_t topmargin)
Set Pad top margin in fraction of the pad height.
Definition: TAttPad.cxx:127
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 Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2878
virtual void SetFillColor(Color_t fcolor)
Definition: TAttFill.h:50
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
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8320