This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

How Do I Replace the EraseMode Property?

Starting in R2014b, the EraseMode property has been removed from all graphics objects. You can still achieve most of the effects produced by EraseMode, such as creating animations or producing overlaid colors, using the techniques described here.

Create Animations

To accumulate a picture by adding data to each frame, use one of these approaches instead of setting the EraseMode property to 'none':

  • Use hold on to retain the current data and add new data to the graph.

  • Use the new animatedline function to create line animations.

  • Use the movie function to play recorded movie frames.

For example, create a line animation using the new animatedline function.

theta = linspace(0,2*pi,1000);
h = animatedline();
axis([0,2*pi,-1,1])

for t = theta
    addpoints(h,t,sin(t));
    drawnow;
end
For more information on creating line animations, see the animatedline reference page and the drawnow function.

Display Changes to Object Data

To immediately display changes to object data, call the drawnow function instead of setting EraseMode to 'xor'.

For example, change the YData for a line and display the updates.

t = linspace(0,2*pi,10000);
y = exp(sin(t));
h = plot(t,y);
for k = 1:0.01:10
   y = exp(sin(t.*k));
   h.YData = y; 
   drawnow
end

Produce Overlaid Colors

To produce overlaid colors, use transparency instead of setting Erasemode to 'xor'.

p1 = patch([0,2,2,0],[0,0,2,2],[1,1,1,1]);
p2 = patch([1,3,3,1],[1,1,3,3],[2,2,2,2]);
p2.FaceAlpha = 0.5;

Increase Rendering Speed

In previous releases, setting the EraseMode property to 'xor' increases the rendering speed. Remove code that sets the EraseMode property to get similar rendering speeds.

See Also

Functions