Draw utilizing GUI handles
1 view (last 30 days)
Show older comments
I have developed a code for drawing dynamically changing neighbor nodes to a moving one. The problem is that when I draw them, and they get changed, it adds the new nodes (yellow color) to the old ones and does not clean the old drawn ones. I am using drawnow and plot and tried lots of variations.
I would much appreciate any help on this. The code is below:
valAnchors=get(handles.hshowAnchors,'Value');
if valAnchors
%hold on;
for j=1:numel(T_R_neighbour(:,1))
node=T_R_neighbour(j,1);
n_X=net(2,node);
n_Y=net(3,node);
sendPointAnch(j) = line('XData',1, 'YData',1, 'EraseMode','normal', ...
'Color','y', 'Marker','.', 'MarkerSize',30);
set(sendPointAnch(j), 'XData',n_X, 'YData',n_Y) %# update point location
end
end
0 Comments
Answers (1)
Walter Roberson
on 28 Jul 2012
MATLAB has some graphic primitives that always always add to the current scene, without erasing anything that is already there. These primitives include line(), patch(), image(), and a few others. (However, plot() is not one of the primitives.)
If you want to erase a graphics object created by a graphics primitive, then delete() it, or cla() to clear the axes.
Instead of creating new lines, you should consider using set() to change the position or color or other attributes of existing lines.
0 Comments
See Also
Categories
Find more on Graphics Performance 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!