Gradient fill with transparency and the "SAME" option.
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 grad2(bool gl = true)
{
auto cnv =
new TCanvas(
"grad2",
"gradient demo 2", 100, 100, 800, 600);
if (!cnv->UseGL() && !cnv->IsWeb())
::Warning(
"grad2",
"This macro requires either OpenGL or Web canvas to correctly handle gradient colors");
auto hist =
new TH1F(
"a2",
"b2", 10, -2., 3.);
auto hist2 =
new TH1F(
"c3",
"d3", 10, -3., 3.);
hist->FillRandom("landau", 100000);
hist2->FillRandom("gaus", 100000);
hist->SetFillColor(grad1);
hist2->SetFillColor(grad2);
hist2->Draw();
hist->Draw("SAME");
}
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
R__EXTERN TStyle * gStyle
static Int_t GetLinearGradient(Double_t angle, const std::vector< Int_t > &colors, const std::vector< Double_t > &positions={})
Static function: Returns the linear gradient color number corresponding to specified parameters.
static Int_t GetColor(const char *hexcolor)
Static method returning color number for color specified by hex color string of form: "#rrggbb",...
1-D histogram with a float per channel (see TH1 documentation)
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
- Authors
- Timur Pocheptsov, Sergey Linev
Definition in file grad2.C.