ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
hist025_THStack_2d_palette_color.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_hist
3
/// \notebook
4
/// \preview Palette coloring for 2D histograms' stack is activated thanks to the option PFC
5
/// (Palette Fill Color).
6
/// When this option is given to `THStack::Draw` the histograms in the
7
/// `THStack` get their color from the current color palette defined by
8
/// `gStyle->SetPalette(...)`. The color is determined according to the number of
9
/// histograms.
10
///
11
/// In this example four 2D histograms are displayed with palette coloring.
12
/// The color of each graph is picked inside the palette number 1.
13
///
14
/// \macro_image
15
/// \macro_code
16
///
17
/// \date November 2022
18
/// \author Olivier Couet
19
20
void
hist025_THStack_2d_palette_color()
21
{
22
gStyle
->SetPalette(1);
23
auto
h1
=
new
TH2F
(
"h1"
,
"h1"
, 20, 0, 6, 20, -4, 4);
24
auto
h2 =
new
TH2F
(
"h2"
,
"h2"
, 20, 0, 6, 20, -4, 4);
25
auto
h3 =
new
TH2F
(
"h3"
,
"h3"
, 20, 0, 6, 20, -4, 4);
26
auto
h4 =
new
TH2F
(
"h4"
,
"h4"
, 20, 0, 6, 20, -4, 4);
27
auto
h5 =
new
TH2F
(
"h5"
,
"h5"
, 20, 0, 6, 20, -4, 4);
28
h2->Fill(2., 0., 5);
29
h3->Fill(3., 0., 10);
30
h4->Fill(4., 0., 15);
31
h5->Fill(5., 0., 20);
32
auto
hs =
new
THStack
(
"hs"
,
"Test of palette colored lego stack"
);
33
hs->Add(
h1
);
34
hs->Add(h2);
35
hs->Add(h3);
36
hs->Add(h4);
37
hs->Add(h5);
38
hs->Draw(
"0lego1 PFC"
);
39
}
gStyle
externTStyle * gStyle
Definition
TStyle.h:442
TH2F
2-D histogram with a float per channel (see TH1 documentation)
Definition
TH2.h:345
THStack
Definition
THStack.h:40
h1
TH1F * h1
Definition
legend1.C:5
tutorials
hist
hist025_THStack_2d_palette_color.C
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1