3

プロットを含む GUI があります。このプロットでは、注釈を追加します。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');
4

3 に答える 3

8

最も簡単な解決策は、注釈に特定のタグを追加することです。

%# create the annotation
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', ...
    'Tag' , 'somethingUnique');

%# delete the annotation
delete(findall(gcf,'Tag','somethingUnique'))
于 2012-08-08T13:44:28.330 に答える
0

findobj関数をざっと見てください。見つけたいオブジェクトのプロパティが十分にわかっている限り、これを使用してハンドルを返し(まだ変数に保存していない場合)、その方法で削除できるはずです。

于 2012-08-07T11:38:28.940 に答える