When copying plot from one subplot position to another using copyobj, the second plot exhibits "hold on" behavior while the first doesn't.
Show older comments
Here's a bare bones version of the code that illustrates the problem. I want both plots to not hold on to previous iterations. While the plot on the top does not hold on to previous plots, the zoomed in plot does. I have even tried putting "hold off;" after every line following subplot(2,1,2) and it does not help.
clear; close all; clc;
counter = 0;
r = 0;
position = [0,0];
while counter < 100
subplot(2,1,1)
fimplicit(@(x,y) (x-position(1)).^2+(y-position(2)).^2-r.^2,'r')
r = r + 0.1; position = position + [0.1,0];
ax = gca; axis equal; axis([-10 10 -10 10]);
zoomed = subplot(2,1,2);
copyobj(get(ax,'Children'),zoomed)
axis equal; axis([-1 1 -1 1]);
pause(0.1)
counter = counter + 1;
end
Accepted Answer
More Answers (1)
Image Analyst
on 23 Feb 2023
0 votes
You never called hold on for the top plot so why should it hold onto previously plotted stuff?
1 Comment
Jacob Ward
on 23 Feb 2023
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!