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.
{
auto h1 =
new TH2F(
"h1",
"h1", 20, 0, 6, 20, -4, 4);
auto h2 =
new TH2F(
"h2",
"h2", 20, 0, 6, 20, -4, 4);
auto h3 =
new TH2F(
"h3",
"h3", 20, 0, 6, 20, -4, 4);
auto h4 =
new TH2F(
"h4",
"h4", 20, 0, 6, 20, -4, 4);
auto h5 =
new TH2F(
"h5",
"h5", 20, 0, 6, 20, -4, 4);
h2->Fill(2., 0., 5);
h3->Fill(3., 0., 10);
auto hs =
new THStack(
"hs",
"Test of palette colored lego stack");
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TStyle * gStyle
2-D histogram with a float per channel (see TH1 documentation)
The Histogram stack class.
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
- Date
- November 2022
- Author
- Olivier Couet
Definition in file hist025_THStack_2d_palette_color.C.