This macro demonstrates semi-transparent pads.
Requires OS X and ROOT configured with –enable-cocoa.
void transparentpad(bool gl = true)
{
auto c1 =
new TCanvas(
"transparentpad",
"transparent pad demo", 10, 10, 900, 500);
if (!
c1->UseGL() && !
c1->IsWeb())
::Warning(
"transparentpad",
"You can see the transparency ONLY in a pdf or png output (\"File\"->\"Save As\" ->...)\n"
"To have transparency in a canvas graphics, you need either OpenGL or Web rendering enabled");
auto h1 =
new TH1F(
"TH1F 1",
"TH1F 1", 100, -1.5, 1.5);
auto h2 =
new TH1F(
"TH1F 2",
"TH1F 2", 100, -1.5, 0.);
h2->FillRandom("gaus");
auto h3 =
new TH1F(
"TH1F 3",
"TH1F 3", 100, 0.5, 2.);
h3->FillRandom("landau");
auto pad1 =
new TPad(
"transparent pad 1",
"transparent pad 1", 0.1, 0.1, 0.7, 0.7);
pad1->Draw();
pad1->cd();
auto pad2 =
new TPad(
"transparent pad 2",
"transparent pad 2", 0.2, 0.2, 0.8, 0.8);
pad2->Draw();
pad2->cd();
h2->Draw();
auto pad3 =
new TPad(
"transparent pad 3",
"transparent pad 3", 0.3, 0.3, 0.9, 0.9);
pad3->Draw();
pad3->cd();
h3->Draw();
}
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
R__EXTERN TStyle * gStyle
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)
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.
The most important graphics class in the ROOT system.
void SetCanvasPreferGL(Bool_t prefer=kTRUE)
- Author
- Timur Pocheptsov
Definition in file transparentpad.C.