How can I plot data in a existing figure?

19 visualizaciones (últimos 30 días)
Mark
Mark el 12 de Jul. de 2013
Hi All,
I am trying to add some data to an existing figure that I load in my script. A simplified example:
Test = open('Test.fig');
figure(Test)
hold on
A = 1:1:100
B = 0:0.02:1.98
plot(A,B)
However, this doesn't give the expected results as it overwrites the opened figure. Removing the 'hold on' makes the opened figure remain active but the line is not added and is nowhere to be found. I have been playing with hgload and copyobj as well but I didn't get it to work.
Any suggestions?
Thanks, Mark
  8 comentarios
Thomas
Thomas el 12 de Jul. de 2013
Editada: Thomas el 12 de Jul. de 2013
I dont think you understand.. its not overwriting.. its covering it with the new plot( since you are plotting the same identical thing) If you plot something else it will show two different line on the same figure as
Test = open('Test.fig');
figure(Test)
pause(2) %pause for you to see that it is bringing ur fig up
hold on
A = 1:1:100
B = 0:0.01:0.99
plot(A,B,'*','color','r')
Mark
Mark el 12 de Jul. de 2013
Thanks, I think I get what you are saying but how can I solve this issue? As I mentioned I basically want to paste some extra lines into an existing figure (with totally different lines).

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 13 de Jul. de 2013
I'm not sure what comes back when you save a figure as a .fig format file and then recall it. I'd save the data into a .mat file instead and then re-create your figure, after reading in the mat file, by plotting all the old data and annotations, then adding your new stuff.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by