_ROOT Version: 6.10/09
_Platform: Built for linuxx8664gcc Compiler: Not Provided
Working on lxplus.cern.ch
The following set of commands:
´
root [0] gStyle->SetOptStat(0);
root [1] TH1F* test = new TH1F (“test”,"",5,0.,5.);
root [2] for (int i=1; i<6; i++) test->SetBinContent(i,float(i))
root [3] test->SetFillColorAlpha(kYellow-10,0.35);
root [4] test->Draw()
root [5] gPad->SetGrid()
´
used to draw the histogram with the pad grid well visible THROUGH it.
Now the histo is no longer transparent.
I even tried the following suggestion which I read in this forum
root [0] gStyle->SetCanvasPreferGL(kTRUE);
As said here, X11 (ie linux) is not one of the platform where the transparency is available. Turning the GL mode “on” should work though (assuming GL is available on you machine). Do you see the transparency if you save your canvas as a PNG file (for instance) ? it should always work.
That’s not possible… It never worked. You were using the GL driver.
So your GL installion does not work.
Run this macro:
void fcavallo(){
auto c = new TCanvas();
gStyle->SetCanvasPreferGL(kTRUE);
gStyle->SetOptStat(0);
TH1F* test = new TH1F ("test","",5,0.,5.);
for (int i=1; i<6; i++) test->SetBinContent(i,float(i));
test->SetFillColorAlpha(kYellow-10,0.35);
test->Draw();
gPad->SetGrid();
c->Print("c.png");
}
The following way:
root -b fcavallo.C
The generated png file c.png should be transparent.
but there must be some magic in there
with:
root -b fcavallo.C (as you said)
it works (just for the saved png file, but that’s what I want)
with:
root
.x fcavallo.C
it does not …
When you run without the option -b the image produced in the .png file is a screen dump of what you see on the screen. As the transparency does not work for X11 then you get a copy without transparency in the .png file.
Whereas when using -b the generated .png is made with a different technique which knows about transparency.