How do I superimpose a transparent patch over a contour plot in MATLAB 7.14 (R2012a)?

10 views (last 30 days)
I have created a contour plot in MATLAB using the CONTOUR command. I now want to draw a transparent patch object that will partly overlap with the contour plot created earlier. I am aware that if the graphics objects front-back order cannot be distinguished by their location in three-dimensional space, then the objects are ordered front-to-back according to the location of their handles in the parent object's 'Children' list. Those objects whose handles appear near the front of the list are in front of those whose handles appear near the end.
Hence I create the contour plot first and then create the overlapping patch. I use the 'facealpha' property to make the patch transparent. However the contours are always rendered on top of the patch instead of the other way around. Changing the renderer does not resolve the issue. The issue becomes more serious when the contour plots are filled and hence the patch is completely hidden by the plot.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Mar 2012
If a line is coplanar with a patch or surface and the zbuffer or OpenGL renderer is being used, the lines appear on top. This also applies to the lines that form the edges of patches and surfaces.
Furthermore in this case, since 'facealpha' property is being used, the Painters renderer cannot display the transparency correctly.
As a workaround, an undocumented feature called 'faceoffsetbias' can be used to enforce the correct stacking order in three dimensional space. Thus if 'hpatch' is the handle to the patch object, setting the 'faceoffsetbias' to a small negative value will ensure that the patch is always rendered correctly on the top.
For example, consider the following set command:
set(hpatch,'faceoffsetbias', -0.001);

More Answers (0)

Products


Release

R2011b

Community Treasure Hunt

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

Start Hunting!