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 3

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 3

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 3

"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:

gui

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
gui Patrick 9 Mar, 2009 15:33:22
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com