我有一个包含情节的图形用户界面。在此图中我添加了注释。当使用 GUI 更改绘图数据时,旧注释将保留,新注释将绘制在旧注释之上。
所以我需要删除旧的注释。
我尝试了以下代码,但没有效果:
set(0,'showhiddenhandles','on')
% look for all axes in the figure of choice:
h_all_axes = findall(gcf,'type','axes');
% get the 'annotation layer' axes handle:
h_anno_axes = double(find(handle(h_all_axes),'-class','graph2d.annotationlayer'));
delete(h_anno_axes);
set(0,'showhiddenhandles','off');
annotationPos = [0.55 0.58 0.6 0.3];
htxtbox = annotation('textbox',annotationPos, ...
'String' ,strtextbox, ...
'FontSize' ,FontSize+1, ...
'FitBoxToText', 'on', ...
'EdgeColor', 'none', ...
'FontName' , 'Courier New');