特定のプロット(グラフ)を削除する方法
99 views (last 30 days)
Show older comments
10本程度の曲線がFigureにプロットされている状態で、ある特定のプロットを数本だけ削除する方法をおしえていただけないでしょうか?
なお、プロットは「plot」「fimplicit」「quiver」が混在している状態です。よろしくお願いいたします。
0 Comments
Accepted Answer
Dyuman Joshi
on 29 Sep 2023
Save the handles of each plot then delete accordingly.
%Example
figure
hold on
[X,Y] = meshgrid(0:6,0:6);
U = 0.25*X;
V = 0.5*Y;
q=quiver(X,Y,U,V,0,'b');
p=plot(X(:),Y(:),'k-');
f1=fimplicit(@(x,y) x.^2-y.^2-1, 'r--');
f2=fimplicit(@(x,y) x.^2.*sin(x)-y, 'g:');
hold off
%Check how many plots there are on the current axis
ax=gca;
ax.Children
%Delete the 2nd fimplicit plot
delete(f2)
%Updated axis after deletion
ax.Children
You can also get the children of the current axis of the figure (i.e. all the plots (and any text), as I have done above) and delete plots accordingly, but that will be tedious.
2 Comments
More Answers (0)
See Also
Categories
Find more on Annotations 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!