Clearing a subplot array of images on a canvas of GUI
2 views (last 30 days)
Show older comments
Hello. I am plotting a set of images whilst in a loop using subplot and its position vector method. In my loop, the values of x and y change. This all works fine and plots to the canvas in my GUI.
positionVector = [os+x, y, width, 0.05];
subplot('Position',positionVector);
hold off;
Does anyone know how to clear this array of images on the canvas??
Thanks Jason
0 Comments
Accepted Answer
Geoff Hayes
on 18 Sep 2014
Jason - do you wish to clear the image from each subplot, or remove the subplots from the canvas/figure?
One way (for either case) is to manage a list of the handles for each subplots
hSubplots = [];
for …
% do stuff
% position subplot
positionVector = [os+x, y, width, 0.05];
h = subplot('Position',positionVector);
% update handle array
hSubplots = [hSubplots ; h];
hold off;
end
Then to delete/remove the subplot from the figure, you would do
delete(hSubplots(k));
cla(hSubplots(k),'reset');
for each subplot k.
7 Comments
Geoff Hayes
on 18 Sep 2014
Jason - see Image Analyst's comment to get the handles of all axes (subplots) on the figure. Their "information" is "stored" within the parent figure.
More Answers (0)
See Also
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!