ROOT
v6-32
Reference Guide
Loading...
Searching...
No Matches
histpalettecolor.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_hist
3
/// \notebook
4
/// Palette coloring for histogram is activated thanks to the options `PFC`
5
/// (Palette Fill Color), `PLC` (Palette Line Color) and `AMC` (Palette Marker Color).
6
/// When one of these options is given to `TH1::Draw` the histogram get its color
7
/// from the current color palette defined by `gStyle->SetPalette(...)`. The color
8
/// is determined according to the number of objects having palette coloring in
9
/// the current pad.
10
///
11
/// In this example five histograms are displayed with palette coloring for lines and
12
/// and marker. The histograms are drawn with markers and error bars and one can see
13
/// the color of each histogram is picked inside the default palette `kBird`.
14
///
15
/// \macro_image
16
/// \macro_code
17
///
18
/// \author Olivier Couet
19
20
void
histpalettecolor()
21
{
22
auto
C
=
new
TCanvas
();
23
24
gStyle
->SetOptTitle(
kFALSE
);
25
gStyle
->SetOptStat(0);
26
27
auto
h1
=
new
TH1F
(
"h1"
,
"Histogram drawn with full circles"
,100,-4,4);
28
auto
h2
=
new
TH1F
(
"h2"
,
"Histogram drawn with full squares"
,100,-4,4);
29
auto
h3
=
new
TH1F
(
"h3"
,
"Histogram drawn with full triangles up"
,100,-4,4);
30
auto
h4 =
new
TH1F
(
"h4"
,
"Histogram drawn with full triangles down"
,100,-4,4);
31
auto
h5 =
new
TH1F
(
"h5"
,
"Histogram drawn with empty circles"
,100,-4,4);
32
33
TRandom3
rng;
34
Double_t
px,
py
;
35
for
(
Int_t
i
= 0;
i
< 25000;
i
++) {
36
rng.
Rannor
(px,
py
);
37
h1
->Fill(px,10.);
38
h2
->Fill(px, 8.);
39
h3
->Fill(px, 6.);
40
h4->Fill(px, 4.);
41
h5->Fill(px, 2.);
42
}
43
44
h1
->SetMarkerStyle(
kFullCircle
);
45
h2
->SetMarkerStyle(
kFullSquare
);
46
h3
->SetMarkerStyle(
kFullTriangleUp
);
47
h4->SetMarkerStyle(
kFullTriangleDown
);
48
h5->SetMarkerStyle(
kOpenCircle
);
49
50
h1
->Draw(
"PLC PMC"
);
51
h2
->Draw(
"SAME PLC PMC"
);
52
h3
->Draw(
"SAME PLC PMC"
);
53
h4->Draw(
"SAME PLC PMC"
);
54
h5->Draw(
"SAME PLC PMC"
);
55
56
gPad
->BuildLegend();
57
}
Int_t
int Int_t
Definition
RtypesCore.h:45
kFALSE
constexpr Bool_t kFALSE
Definition
RtypesCore.h:101
Double_t
double Double_t
Definition
RtypesCore.h:59
kFullTriangleDown
@ kFullTriangleDown
Definition
TAttMarker.h:56
kFullSquare
@ kFullSquare
Definition
TAttMarker.h:55
kFullTriangleUp
@ kFullTriangleUp
Definition
TAttMarker.h:55
kFullCircle
@ kFullCircle
Definition
TAttMarker.h:55
kOpenCircle
@ kOpenCircle
Definition
TAttMarker.h:56
py
Int_t py
Definition
TGraphAsymmErrors.cxx:1302
i
Int_t i
Definition
TGraphAsymmErrors.cxx:1306
gStyle
R__EXTERN TStyle * gStyle
Definition
TStyle.h:433
gPad
#define gPad
Definition
TVirtualPad.h:305
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:621
TRandom3
Random number generator class based on M.
Definition
TRandom3.h:27
TRandom::Rannor
virtual void Rannor(Float_t &a, Float_t &b)
Return 2 numbers distributed following a gaussian with mean=0 and sigma=1.
Definition
TRandom.cxx:507
h1
TH1F * h1
Definition
legend1.C:5
TMVA_SOFIE_GNN_Parser.h2
h2
Definition
TMVA_SOFIE_GNN_Parser.py:188
TMVA_SOFIE_GNN_Parser.h3
h3
Definition
TMVA_SOFIE_GNN_Parser.py:189
TMath::C
constexpr Double_t C()
Velocity of light in .
Definition
TMath.h:114
tutorials
hist
histpalettecolor.C
ROOT v6-32 - Reference Guide Generated on Sun May 17 2026 02:44:15 (GVA Time) using Doxygen 1.13.2