This macro demonstrates how to create and use linear gradients to fill a histogram or a pad.
To use this macro you need OpenGL enabled in pad: either set OpenGL.CanvasPreferGL to 1 in $ROOTSYS/etc/system.rootrc; or call gStyle->SetCanvasPreferGL(kTRUE);
before canvas created.
void grad()
{
::Error(
"grad",
"failed to create new custom colors");
return;
}
TCanvas *
const cnv =
new TCanvas(
"gradient demo 1",
"gradient demo 1", 100, 100, 600, 600);
::Error(
"grad",
"This macro requires OpenGL");
delete cnv;
return;
}
const Color_t &frameGradient = colorIndices[2];
{
new TColor(colorIndices[0], 0.25, 0.25, 0.25,
"special pad color1", 0.55);
new TColor(colorIndices[1], 1., 1., 1.,
"special pad color2", 0.05);
const Double_t locations[] = {0., 0.2, 0.8, 1.};
const Color_t gradientIndices[4] = {colorIndices[0], colorIndices[1], colorIndices[1], colorIndices[0]};
}
const Color_t &padGradient = colorIndices[3];
{
const Color_t gradientIndices[4] = {30, 38};
}
const Color_t &histGradient = colorIndices[4];
{
const Double_t locations[3] = {0., 0.5, 1.};
}
TH1F *
const hist =
new TH1F(
"a1",
"b1", 20, -3., 3.);
}
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
R__EXTERN TStyle * gStyle
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
void SetFrameFillColor(Color_t color=1)
The color creation and management class.
1-D histogram with a float per channel (see TH1 documentation)}
virtual void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Fill histogram following distribution in function fname.
void Draw(Option_t *option="") override
Draw this histogram with options.
Define a linear color gradient.
void SetStartEnd(const Point &p1, const Point &p2)
Set end and start.
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
unsigned FindFreeCustomColorIndices(T(&indices)[N])