Thread Subject: Clearing drawn lines from a figure window

Subject: Clearing drawn lines from a figure window

From: Patrick

Date: 9 Mar, 2009 19:20:17

Message: 1 of 4

Is there any way to clear lines drawn with the line() command from a figure window? clear() doesn't seem to work. Clearing the entire figure resets the axes to defaults, and its an image window where you don't want axes. I'm not sure how to redraw the image though if thats the only way to do it I will need a ay to redraw it quickly.

Subject: Clearing drawn lines from a figure window

From: Ashish Uthama

Date: 9 Mar, 2009 19:41:42

Message: 2 of 4

On Mon, 09 Mar 2009 15:20:17 -0400, Patrick <praphael@bcm.tmc.edu> wrote:

> Is there any way to clear lines drawn with the line() command from a
> figure window? clear() doesn't seem to work. Clearing the entire
> figure resets the axes to defaults, and its an image window where you
> don't want axes. I'm not sure how to redraw the image though if thats
> the only way to do it I will need a ay to redraw it quickly.


help line
...
     LINE returns a column vector of handles to LINE objects,
     one handle per line. LINEs are children of AXES objects.
...


You can delete this handle to remove the line from the figure.

lh=line(<...>)
%use the below when you want to delete the line
delete(lh)

If you cant/dont want to do the above, you could use the FINDOBJ to search
for the line object (tricky if you have multiple lines). This is just to
let you know of an alternative.. I would recommend using the first
approach.

Subject: Clearing drawn lines from a figure window

From: Adam

Date: 9 Mar, 2009 19:49:01

Message: 3 of 4

"Patrick " <praphael@bcm.tmc.edu> wrote in message <gp3q5h$8te$1@fred.mathworks.com>...
> Is there any way to clear lines drawn with the line() command from a figure window? clear() doesn't seem to work. Clearing the entire figure resets the axes to defaults, and its an image window where you don't want axes. I'm not sure how to redraw the image though if thats the only way to do it I will need a ay to redraw it quickly.

one way
hLine = line([1 1], [0 0]); % draw line

delete(hLine) % delete line

If you're going to reuse the line later this may be preferable
set(hline, 'XData', [], 'YData', [])

If you need to update the figure
drawnow()

~Adam

Subject: Clearing drawn lines from a figure window

From: KYAW KYAW

Date: 10 Nov, 2011 09:54:28

Message: 4 of 4

Dear Patrick,

Thank you for your clearing ways and I am looking for to remove some segments of the line only.
How should and please advise me.

Thanks and best regards
Kyaw

"Adam" wrote in message <gp3rrd$2ka$1@fred.mathworks.com>...
> "Patrick " <praphael@bcm.tmc.edu> wrote in message <gp3q5h$8te$1@fred.mathworks.com>...
> > Is there any way to clear lines drawn with the line() command from a figure window? clear() doesn't seem to work. Clearing the entire figure resets the axes to defaults, and its an image window where you don't want axes. I'm not sure how to redraw the image though if thats the only way to do it I will need a ay to redraw it quickly.
>
> one way
> hLine = line([1 1], [0 0]); % draw line
>
> delete(hLine) % delete line
>
> If you're going to reuse the line later this may be preferable
> set(hline, 'XData', [], 'YData', [])
>
> If you need to update the figure
> drawnow()
>
> ~Adam

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
removing segmen... KYAW KYAW 10 Nov, 2011 04:54:31
gui Patrick 9 Mar, 2009 15:33:22
rssFeed for this Thread

Contact us at files@mathworks.com