Reputation: 2598
I am writing a GUI program. In one part of it I show an image on my axes and then plot a red * on my image then I do some processes on the image and now I want to delete the red * How can I do that?
Upvotes: 5
Views: 5900
Reputation: 16193
In short, you need to use the 'visible' flag. You can access this via the children of the current axis object. See the example code below. You can use the final line of code to set the visibility of the red 'X' on and off . . .
close all;
plot ([1 2 3 4], [1 2 1 2])
hold on
plot(2.5, 1.5, 'xr')
dataH = get(gca, 'Children');
set( dataH(1), 'Linewidth', 10, 'MarkerSize', 30 )
pause
set( dataH(1), 'visible', 'off' )
pause
set( dataH(1), 'visible', 'on' )
pause
set( dataH(1), 'visible', 'off' )
pause
set( dataH(1), 'visible', 'on' )
Upvotes: 3