有没有办法从现有轴中删除单个图?

发布于 2024-09-12 15:34:17 字数 120 浏览 3 评论 0原文

有没有一种简单的方法可以从一组轴中删除绘制的线,而不清除轴上的其他所有内容?我正在尝试实现一个带有包含多个数据集的列表框的 GUI。我可以让回调函数绘制所选数据,但我不确定当我取消选择数据集时如何“取消绘制”它。有什么想法吗?

Is there an easy way to remove a plotted line from a set of axes without clearing everything else on the axes? I'm trying to implement a GUI with a listbox containing several data sets. I can make the callback function plot the selected data, but I'm not sure how to 'unplot' it when I deselect a data set. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只等公子 2024-09-19 15:34:17

如果保存创建的图形对象的句柄,则可以调用 DELETE 将其从绘图中删除:

hLine = plot(...);  %# Create a line with PLOT
delete(hLine);      %# ...and delete it

或者,如果您没有将句柄保存在变量中,则可以使用 FINDOBJ,找到后将其删除。

如果您实际上不想删除它,而只是打开和关闭线条的可见性,则可以设置'Visible' 相应图形对象的属性

set(hLine,'Visible','off');  %# Make it invisible
set(hLine,'Visible','on');   %# Make it visible

If you save a handle to the created graphics object, you can call DELETE on it to remove it from the plot:

hLine = plot(...);  %# Create a line with PLOT
delete(hLine);      %# ...and delete it

Alternatively, if you didn't save the handle in a variable, you can search for it using FINDOBJ, then delete it when you find it.

If you don't actually want to delete it, but simply turn the visibility of the line on and off, you can set the 'Visible' property of the graphics object accordingly:

set(hLine,'Visible','off');  %# Make it invisible
set(hLine,'Visible','on');   %# Make it visible
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文