Why is the "Layer" property of my axes ignored when the axes contains objects with 'EraseMode' property other than 'normal' in MATLAB?

1 view (last 30 days)
I use the following code to draw a patch object:
x = [0 0;0 1;1 1];
y = [1 1;2 2;2 1];
z = [1 1;1 1;1 1];
tcolor(1,1,1:3) = [1 1 1];
tcolor(1,2,1:3) = [.7 .7 .7];
bb = patch(x,y,z,tcolor, 'erasemode', 'background');
set(gca, 'Layer', 'top');
grid on;
Since I have set the 'Layer' property of the axes to 'top', I expect the patch objects to render behind the grid lines. However, in the resulting plot, the patch objects are rendered in front of the grid lines, contrary to the 'Layer' property setting.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
Objects with 'EraseMode' property other than 'normal' are rendered last after all other components of the figure. Therefore, they cannot obey the 'Layer' property of the axes. Only objects with 'EraseMode' set to 'normal' work with the 'Layer' property of axes.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!