Palette coloring for TH1
Palette coloring for histogram is activated thanks to the options PFC
(Palette Fill Color), PLC
(Palette Line Color) and PMC
(Palette Marker Color). When one of these options is given to TH1::Draw
the histogram gets its color from the current color palette defined by gStyle->SetPalette(...)
. The color is determined according to the number of objects having palette coloring in the current pad.
In this example five histograms are displayed with palette coloring for lines and and marker. The histograms are drawn with markers and error bars and one can see the color of each histogram is picked inside the default palette kBird
.
{
auto *
h1 =
new TH1D(
"h1",
"Histogram drawn with full circles", 100, -4, 4);
auto *h2 =
new TH1D(
"h2",
"Histogram drawn with full squares", 100, -4, 4);
auto *h3 =
new TH1D(
"h3",
"Histogram drawn with full triangles up", 100, -4, 4);
auto *
h4 =
new TH1D(
"h4",
"Histogram drawn with full triangles down", 100, -4, 4);
auto *
h5 =
new TH1D(
"h5",
"Histogram drawn with empty circles", 100, -4, 4);
for (int i = 0; i < 25000; i++) {
h2->Fill(val, 8.);
h3->Fill(val, 6.);
}
h2->Draw("SAME PLC PMC");
h3->Draw("SAME PLC PMC");
h4->Draw(
"SAME PLC PMC");
h5->Draw(
"SAME PLC PMC");
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TStyle * gStyle
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
1-D histogram with a double per channel (see TH1 documentation)
virtual Int_t Fill(Double_t x)
Increment bin with abscissa X by 1.
void Draw(Option_t *option="") override
Draw this histogram with options.
Random number generator class based on M.
void SetOptTitle(Int_t tit=1)
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
- Date
- November 2024
- Author
- Olivier Couet
Definition in file hist005_TH1_palettecolor.C.