ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
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);
23
h
->SetCanExtend(
TH1::kAllAxes
);
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
}
h
#define h(i)
Definition
RSha256.hxx:106
Int_t
int Int_t
Definition
RtypesCore.h:45
r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Definition
TGWin32VirtualXProxy.cxx:168
i
Int_t i
Definition
TGraphAsymmErrors.cxx:1306
gRandom
R__EXTERN TRandom * gRandom
Definition
TRandom.h:62
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:621
TH1::kAllAxes
@ kAllAxes
Definition
TH1.h:76
TPaveText
A Pave (see TPave) with text, lines or/and boxes inside.
Definition
TPaveText.h:21
pt
TPaveText * pt
Definition
entrylist_figure1.C:7
c1
return c1
Definition
legend1.C:41
tutorials
hist
hlabels1.C
ROOT v6-32 - Reference Guide Generated on Tue May 19 2026 02:47:09 (GVA Time) using Doxygen 1.13.2