Color transparency doesn't work any more


_ROOT Version: 6.10/09
_Platform: Built for linuxx8664gcc
Compiler: Not Provided

Working on
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);

wit no success.

Thank you for your help!

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.

I just tried your few lines on Mac where the transparency works in all cases (GL mode and native mode). I did a screen dump. Which is fine:

no… ufortunately not even the .png file shows a transparent histogram.

Two (side) notes:

  1. It used to work even with X11 some two years ago
  2. I noticed the following error messages:
    root [2] test->SetFillColorAlpha(kYellow-10,0.35);
    root [3] gStyle->SetCanvasPreferGL(kTRUE);
    root [4] test->Draw()
    Error in < TX11GLManager::CreateContext>: glXCreateContext failed
    Error in < TRootCanvas::CreateCanvas>: GL context creation failed.

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();
   TH1F* test = new TH1F ("test","",5,0.,5.);
   for (int i=1; i<6; i++) test->SetBinContent(i,float(i));

The following way:

root -b fcavallo.C

The generated png file c.png should be transparent.


but there must be some magic in there :smiley:
root -b fcavallo.C (as you said)
it works (just for the saved png file, but that’s what I want)
.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.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.