ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
labels1.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_graphs
3
/// \notebook
4
/// Setting alphanumeric labels in a 1-d histogram.
5
///
6
/// \macro_image
7
/// \macro_code
8
///
9
/// \author Rene Brun
10
11
void
labels1()
12
{
13
Int_t
i
;
14
const
Int_t
nx = 20;
15
const
char
*people[nx] = {
"Jean"
,
"Pierre"
,
"Marie"
,
"Odile"
,
16
"Sebastien"
,
"Fons"
,
"Rene"
,
"Nicolas"
,
"Xavier"
,
"Greg"
,
17
"Bjarne"
,
"Anton"
,
"Otto"
,
"Eddy"
,
"Peter"
,
"Pasha"
,
18
"Philippe"
,
"Suzanne"
,
"Jeff"
,
"Valery"
};
19
TCanvas
*
c1
=
new
TCanvas
(
"c1"
,
"demo bin labels"
,10,10,900,500);
20
c1
->SetGrid();
21
c1
->SetBottomMargin(0.15);
22
TH1F
*
h
=
new
TH1F
(
"h"
,
"test"
,nx,0,nx);
23
h
->SetFillColor(38);
24
for
(
i
=0;
i
<5000;
i
++)
h
->Fill(
gRandom
->Gaus(0.5*nx,0.2*nx));
25
h
->SetStats(0);
26
for
(
i
=1;
i
<=nx;
i
++)
h
->GetXaxis()->SetBinLabel(
i
,people[
i
-1]);
27
h
->Draw();
28
TPaveText
*
pt
=
new
TPaveText
(0.6,0.7,0.98,0.98,
"brNDC"
);
29
pt
->SetFillColor(18);
30
pt
->SetTextAlign(12);
31
pt
->AddText(
"Use the axis Context Menu LabelsOption"
);
32
pt
->AddText(
" \"a\" to sort by alphabetic order"
);
33
pt
->AddText(
" \">\" to sort by decreasing values"
);
34
pt
->AddText(
" \"<\" to sort by increasing values"
);
35
pt
->Draw();
36
}
h
#define h(i)
Definition
RSha256.hxx:106
Int_t
int Int_t
Definition
RtypesCore.h:45
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
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
graphs
labels1.C
ROOT v6-32 - Reference Guide Generated on Tue May 19 2026 02:47:09 (GVA Time) using Doxygen 1.13.2