Why does using PATCH with transparency cause the axes to disappear in MATLAB?

If I use the following code, the X axis disappears when transparency is used :
t = linspace(0,2*pi,128);
y1 = 5*cos(t);
y2= 10*sin(t);
plot(t,y1,'b')
hold on
area(y2,t)
alpha(0.5)
If I do not create a line plot, then the Y axis disappears:
t = linspace(0,2*pi,128);
y2= 10*sin(t);
area(y2,t)
alpha(0.5)

 Accepted Answer

This has been verified as a bug in MATLAB 6.5 (R13) and later versions in the way that axes are rendered in hardware accelerated OpenGL, when transparency is used.
There are currently no known fixes to the bug itself, but there are a couple workarounds.
1. Set the OpenGL renderer to use software acceleration instead of the hardware acceleration.
opengl software
The disadvantage of this method is that with resource intensive figures, software acceleration may be slower compared to hardware acceleration. Please refer to the OpenGL renderer documentation for more info.
2. Update graphics card drivers or try a different graphics card. Older driver versions may or may not work. A solution is not guaranteed.

More Answers (1)

I've been dealing with this bug on matlab vs 2014a for a few days and wanted to share my solution.
My code was setting transparency (alpha) of objects in a plot and then setting axis limits. The axes disappeared after setting the axis limits. I changed the order of these commands so that axis limits were set before setting transparency. This fixed the problem for all of my subplots that were affected by this bug. Hope that helps.
Adam Danz

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products

Release

R2011a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!