ROOT
git-r3/HEAD
Reference Guide
Loading...
Searching...
No Matches
hist027_THStack_palette_color.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_hist
3
/// \notebook
4
/// \preview Palette coloring for histograms' stack 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 `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 histograms are displayed with palette coloring.
12
/// The color of each histogram is picked inside the palette `kOcean`.
13
///
14
/// \macro_image
15
/// \macro_code
16
///
17
/// \date December 2018
18
/// \author Olivier Couet
19
20
void
hist027_THStack_palette_color()
21
{
22
auto
hs =
new
THStack
(
"hs"
,
"Stacked 1D histograms colored using kOcean palette"
);
23
24
gStyle
->SetPalette(
kOcean
);
25
26
// Create three 1-d histograms and add them in the stack
27
auto
h1st =
new
TH1F
(
"h1st"
,
"test hstack"
, 100, -4, 4);
28
h1st->FillRandom(
"gaus"
, 20000);
29
hs->Add(h1st);
30
31
auto
h2st =
new
TH1F
(
"h2st"
,
"test hstack"
, 100, -4, 4);
32
h2st->FillRandom(
"gaus"
, 15000);
33
hs->Add(h2st);
34
35
auto
h3st =
new
TH1F
(
"h3st"
,
"test hstack"
, 100, -4, 4);
36
h3st->FillRandom(
"gaus"
, 10000);
37
hs->Add(h3st);
38
39
// draw the stack
40
hs->Draw(
"pfc nostack"
);
41
}
kOcean
@ kOcean
Definition
TColor.h:122
gStyle
externTStyle * gStyle
Definition
TStyle.h:442
TH1F
1-D histogram with a float per channel (see TH1 documentation)
Definition
TH1.h:878
THStack
Definition
THStack.h:40
tutorials
hist
hist027_THStack_palette_color.C
ROOTgit-r3/HEAD - Reference Guide Generated on
(GVA Time) using Doxygen 1.16.1