This macro demonstrates semi-transparent pads.
One uses fill styles between 4000 and 4100 to configure objects transparency On OpenGL or Mac/Cocoa or Web-based canvas pads will be drawn with transparent colors. On X11 pixmap transformation performed to partially emulate pads transparency Also demonstrated usage of transparent fill styles for stats box
void transparentpad(bool gl = true)
{
gStyle->SetCanvasPreferGL(gl);
auto c1 =
new TCanvas(
"c1",
"transparent pad demo", 10, 10, 900, 500);
if (!
c1->UseGL() && !
c1->IsWeb() && !
gVirtualX->InheritsFrom(
"TGCocoa"))
"To have real transparency in a canvas graphics, you need either OpenGL or Mac/Cocoa 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->SetFillColor(
kPink);
pad1->SetFillStyle(4040);
auto pad2 =
new TPad(
"transparent pad 2",
"transparent pad 2", 0.2, 0.2, 0.8, 0.8);
pad2->SetFillStyle(4035);
pad2->Add(h2);
auto pad3 =
new TPad(
"transparent pad 3",
"transparent pad 3", 0.3, 0.3, 0.9, 0.9);
pad3->SetFillColor(
kBlue);
pad3->SetFillStyle(4030);
pad3->Add(h3);
auto stats2 =
dynamic_cast<TPaveStats *
>(h2->FindObject(
"stats"));
if (stats2) {
stats2->SetFillStyle(4050);
}
auto stats3 =
dynamic_cast<TPaveStats *
>(h3->FindObject(
"stats"));
if (stats3) {
stats3->SetFillStyle(4050);
}
}
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
1-D histogram with a float per channel (see TH1 documentation)
The most important graphics class in the ROOT system.
- Authors
- Timur Pocheptsov, Sergey Linev
Definition in file transparentpad.C.