Matlab area() edge colors cover the axes lines, is there a work around?

moorepants picture moorepants · May 31, 2011 · Viewed 8.8k times · Source
figure('Color', 'w')
box on
x = 1:10;
y = 5 * x + 2;
area(x, y, 'FaceColor', 'b', 'EdgeColor', 'b')

This code creates a figure with the area under the curve shaded blue. The EdgeColor property sets the trapezoidal line around the filled area to blue but this covers up the black axes lines and tick marks. I'm not sure why it does this or how to prevent it. I thought the axis would always have precedence. I can't figure out how to bring the axes lines and tick marks back into view over laying the filled area. Any ideas how to get this to work?

Update: 'EdgeColor', 'None' does not seem to work either.

Answer

astay13 picture astay13 · May 31, 2011

Try adding the following after your code for the figure (gca refers to the current axes):

set(gca,'Layer','top')