How can I plot data in a existing figure?

19 views (last 30 days)
Mark
Mark on 12 Jul 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 Comments
Thomas
Thomas on 12 Jul 2013
Edited: Thomas on 12 Jul 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 on 12 Jul 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).

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 13 Jul 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.

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!