clear one plot in multiple (hold) figure

I have a single figure/plot that contains multiple plots commands (not subplots - just multiple data sets). I need to be able to add the data to the current figure, see how it looks, and clear it if doesnt fit my visual criteria.
Any suggestions?
clf clears the entire figure. I just want to clear the last data set I added to the figure.

 Respuesta aceptada

the cyclist
the cyclist el 16 de Feb. de 2011
figure
hold on
h1 = plot(1:10,'r');
h2 = plot(2:11,'g');
if <your condition doesn't hold>
set(h2,'Visible','off')
end

3 comentarios

Umair  Ahmed
Umair Ahmed el 22 de Jun. de 2020
Is there a way to bring back a signal after deleting it? or if we can use plot/unplot all the signals in the plot by using something like a check mark?
Rik
Rik el 22 de Jun. de 2020
If you're using this code you aren't deleting the plot. You are just making the plot invisible. The solution is to set visible to 'on' again if you want to show the plot.
Tomas
Tomas el 18 de Nov. de 2022
Now if I were top do this inside a callback function i would do e.g.
h1 = plot(1:10,'r');
then how can I do the set(h2,'Visible','off') in a separate callback function?

Iniciar sesión para comentar.

Más respuestas (3)

Matt Tearle
Matt Tearle el 16 de Feb. de 2011
In addition to the cyclist's answer, you can also do
delete(h2)
to actually delete the line, rather than just hide it. Also, if you didn't store the handles on plotting ( h1 = plot(...) ) you can find them after the fact using findobj
h = findobj('type','line')
finds a vector of handles to all line objects. You could then delete(h(1))

3 comentarios

Jiro Doke
Jiro Doke el 27 de Feb. de 2011
Another option (if you don't have the handle), is to click on the line that you want to delete and type:
delete(gco)
Wencai Lee
Wencai Lee el 6 de Abr. de 2011
Hi Jiro,
Do you know how to undo one step after using the delete(gco)?
Thanks!
Eric T
Eric T el 18 de Mzo. de 2016
This seems a nice, principled answer. Don't like making them invisible because that takes up memory, def prefer to delete them!

Iniciar sesión para comentar.

Sai
Sai el 18 de En. de 2017

3 votos

Go to 'View' and click on the 'Plot Browser' to enable it. There you can check/uncheck the plots in the figure
Ashton
Ashton el 16 de Feb. de 2011

1 voto

Thanks guys!

1 comentario

Matt Tearle
Matt Tearle el 16 de Feb. de 2011
You're welcome. And now the obligatory message: to help others who might have the same question, it would be great if you could vote for and/or accept answers that you think should be given prominence. Thanks. (I know there's only a couple of answers in this case, but it's good practice to let everyone know "answer X solved my problem")

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Performance en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 16 de Feb. de 2011

Comentada:

el 18 de Nov. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by