Logo ROOT   6.07/09
Reference Guide
hlabels1.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_hist
3 /// \notebook
4 /// 1-D histograms with alphanumeric labels
5 ///
6 /// \macro_image
7 /// \macro_code
8 ///
9 /// \author Rene Brun
10 
11 TCanvas *hlabels1()
12 {
13  const Int_t nx = 20;
14  const char *people[nx] = {"Jean","Pierre","Marie","Odile","Sebastien",
15  "Fons","Rene","Nicolas","Xavier","Greg","Bjarne","Anton","Otto",
16  "Eddy","Peter","Pasha","Philippe","Suzanne","Jeff","Valery"};
17  TCanvas *c1 = new TCanvas("c1","demo bin labels",10,10,900,500);
18  c1->SetGrid();
19  c1->SetTopMargin(0.15);
20  TH1F *h = new TH1F("h","test",3,0,3);
21  h->SetStats(0);
22  h->SetFillColor(38);
24  for (Int_t i=0;i<5000;i++) {
25  Int_t r = gRandom->Rndm()*20;
26  h->Fill(people[r],1);
27  }
28  h->LabelsDeflate();
29  h->Draw();
30  TPaveText *pt = new TPaveText(0.7,0.85,0.98,0.98,"brNDC");
31  pt->SetFillColor(18);
32  pt->SetTextAlign(12);
33  pt->AddText("Use the axis Context Menu LabelsOption");
34  pt->AddText(" \"a\" to sort by alphabetic order");
35  pt->AddText(" \">\" to sort by decreasing values");
36  pt->AddText(" \"<\" to sort by increasing values");
37  pt->Draw();
38  return c1;
39 }
const int nx
Definition: kalman.C:16
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
Definition: TH1.cxx:3127
virtual void Draw(Option_t *option="")
Draw this pavetext with its current attributes.
Definition: TPaveText.cxx:211
return c1
Definition: legend1.C:41
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
Definition: THist.hxx:302
TH1 * h
Definition: legend2.C:5
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
tomato 1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:575
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:130
virtual void SetGrid(Int_t valuex=1, Int_t valuey=1)
Definition: TPad.h:318
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
Definition: TAttText.h:47
virtual Double_t Rndm()
Machine independent random number generator.
Definition: TRandom.cxx:512
TPaveText * pt
TRandom2 r(17)
virtual void Draw(Option_t *option="")
Draw this histogram with options.
Definition: TH1.cxx:2853
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition: TAttFill.h:42
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:4783
R__EXTERN TRandom * gRandom
Definition: TRandom.h:66
The Canvas class.
Definition: TCanvas.h:41
A Pave (see TPave) with text, lines or/and boxes inside.
Definition: TPaveText.h:27
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:5930
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition: TH1.cxx:8058