Why does PLOT draw on the wrong axes if I invoke the DRAWNOW command in MATLAB 7.0 (R14)?

7 views (last 30 days)
If multiple figures are open, invoking the DRAWNOW command may result in plots being applied to wrong axes. The following reproduction steps illustrate the incorrect drawing behavior with DRAWNOW. (Note: the term plot is being used to refer to a general graphics drawing operation on an axes, not limited to the PLOT function)
figure(1);
plot(sin(1:10))
figure(2);
drawnow;
plot(exp(1:10))
close(2);
The exponential plot that should have been rendered to figure 2 is incorrectly rendered to figure 1. Removing the drawnow command results in expected behavior in which the correct plot is rendered to the correct figure.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
We have verified that there is a bug in MATLAB 7.0 (R14) in the way that MATLAB determines the figure to render the plot. To work around this issue, you can specify the axes on which the plot should be rendered:
fig1 = figure;
axes1 = axes('Parent',fig1);
plot(sin(1:10),'Parent',axes1)
fig2 = figure;
drawnow;
axes2=axes('Parent',fig2);
plot(exp(1:10),'Parent',axes2)

More Answers (0)

Categories

Find more on Graphics Performance 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!