特定のプロット(グラフ)を削除する方法

65 次查看(过去 30 天)
高木 範明
高木 範明 2023-9-29
10本程度の曲線がFigureにプロットされている状態で、ある特定のプロットを数本だけ削除する方法をおしえていただけないでしょうか?
なお、プロットは「plot」「fimplicit」「quiver」が混在している状態です。よろしくお願いいたします。

采纳的回答

Dyuman Joshi
Dyuman Joshi 2023-9-29
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
ans =
4×1 graphics array: ImplicitFunctionLine ImplicitFunctionLine Line Quiver
%Delete the 2nd fimplicit plot
delete(f2)
%Updated axis after deletion
ax.Children
ans =
3×1 graphics array: ImplicitFunctionLine Line Quiver
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 个评论
高木 範明
高木 範明 2023-9-30
Thank you for your prompt guidance. I also apologize for the delay in thanking you.
I see, now I understand that I can erase the plot in this way. Really, it was a great help.
早々のご教示をありがとうございます。また、御礼が遅れたことをお詫びいたします。
なるほど、このようにすればプロットを消すことができることを理解しました。本当に、助かりました。
Dyuman Joshi
Dyuman Joshi 2023-9-30
You are welcome! Glad to have helped.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 ライン プロット 的更多信息

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!