Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
19void thstackpalettecolor()
20{
21 auto hs = new THStack("hs","Stacked 1D histograms colored using kOcean palette");
22
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}
@ kOcean
Definition TColor.h:110
R__EXTERN TStyle * gStyle
Definition TStyle.h:412
1-D histogram with a float per channel (see TH1 documentation)}
Definition TH1.h:575
The Histogram stack class.
Definition THStack.h:38
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
Definition TStyle.cxx:1782