有没有办法从现有轴上删除单个图? [英] Is there a way to remove a single plot from existing axes?

查看:74
本文介绍了有没有办法从现有轴上删除单个图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种简便的方法可以从一组轴上删除一条绘制的线而无需清除轴上的所有其他内容?我正在尝试使用包含多个数据集的列表框来实现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?

推荐答案

如果将句柄保存到创建的图形对象,则可以调用

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

这篇关于有没有办法从现有轴上删除单个图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆