Palette coloring for 2D histograms' stack is activated thanks to the option PFC
(Palette Fill Color).
When this option is given to THStack::Draw
the histograms in the THStack
get their color from the current color palette defined by gStyle->SetPalette(...)
. The color is determined according to the number of histograms.
In this example four 2D histograms are displayed with palette coloring. The color of each graph is picked inside the palette number 1.
void thstack2palettecolor () {
TH2F * h2 =
new TH2F(
"h2",
"h1",20,0,6,20,-4,4);
TH2F * h3 =
new TH2F(
"h3",
"h1",20,0,6,20,-4,4);
TH2F * h4 =
new TH2F(
"h4",
"h1",20,0,6,20,-4,4);
TH2F * h5 =
new TH2F(
"h5",
"h1",20,0,6,20,-4,4);
THStack * hs =
new THStack(
"hs",
"Test of palette colored lego stack");
}
R__EXTERN TStyle * gStyle
2-D histogram with a float per channel (see TH1 documentation)}
Int_t Fill(Double_t)
Invalid Fill method.
The Histogram stack class.
virtual void Draw(Option_t *chopt="")
Draw this multihist with its current attributes.
virtual void Add(TH1 *h, Option_t *option="")
add a new histogram to the list Only 1-d and 2-d histograms currently supported.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=0, Float_t alpha=1.)
See TColor::SetPalette.
- Author
- Olivier Couet
Definition in file thstack2palettecolor.C.