How can I plot data in a existing figure?
이전 댓글 표시
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
Thomas
2013년 7월 12일
Do you want to see two figures?
Mark
2013년 7월 12일
That is exactly what your code does. Are you sure you are not overwriting the same exact plot and so you can not see it try..
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.02:1.98
plot(A,B,'*','color','r')
Mark
2013년 7월 12일
Mark
2013년 7월 12일
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
2013년 7월 12일
답변 (1개)
Image Analyst
2013년 7월 13일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!