ROOT
6.30.04
Reference Guide
All
Namespaces
Files
Pages
thstackpalettecolor.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_hist
3
/// \notebook
4
/// 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
/// \author Olivier Couet
18
19
void
thstackpalettecolor()
20
{
21
auto
hs =
new
THStack(
"hs"
,
"Stacked 1D histograms colored using kOcean palette"
);
22
23
gStyle->SetPalette(kOcean);
24
25
// Create three 1-d histograms and add them in the stack
26
auto
h1st =
new
TH1F(
"h1st"
,
"test hstack"
,100,-4,4);
27
h1st->FillRandom(
"gaus"
,20000);
28
hs->Add(h1st);
29
30
auto
h2st =
new
TH1F(
"h2st"
,
"test hstack"
,100,-4,4);
31
h2st->FillRandom(
"gaus"
,15000);
32
hs->Add(h2st);
33
34
auto
h3st =
new
TH1F(
"h3st"
,
"test hstack"
,100,-4,4);
35
h3st->FillRandom(
"gaus"
,10000);
36
hs->Add(h3st);
37
38
// draw the stack
39
hs->Draw(
"pfc nostack"
);
40
}
tutorials
hist
thstackpalettecolor.C
Generated on Tue May 5 2020 14:03:46 for ROOT by
1.8.5