Logo ROOT  
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/// 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
21{
22 auto hs = new THStack("hs", "Stacked 1D histograms colored using kOcean palette");
23
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}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kOcean
Definition TColor.h:120
R__EXTERN TStyle * gStyle
Definition TStyle.h:442
1-D histogram with a float per channel (see TH1 documentation)
Definition TH1.h:645
The Histogram stack class.
Definition THStack.h:40
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1890