필터 지우기
필터 지우기

How to save a *.fig with the legend included?

조회 수: 2 (최근 30일)
Olivier
Olivier 2013년 5월 26일
답변: Adam Neuf 2015년 5월 21일
Hi,
My question is quite simple :
I have the following code :
figure;
A = loglog(...)
hold on
B = loglog(...)
C = loglog(...)
str = sprintf('3SRS - Run %d - Dir %d', run, dir);
title(str);
xlabel('Fréquences [Hz]');
ylabel('Accel (G)');
legend( [A B C], '...','...','...' );
filename = str;
saveas(figure(1),filename,'fig');
close figure 1
And it appears that the figure is correctly saved in .fig but the legend isn't displayed when i open the saved *.fig
Thanks in advance. O.G.
  댓글 수: 2
Artur M. G. Lourenço
Artur M. G. Lourenço 2013년 5월 26일
the code is not work. It's a example or the real code?
Olivier
Olivier 2013년 5월 26일
Hm yes sorry, it was just an example... The '...' are full filled with my data. I put some '...' because you coudn't acces to my data.

댓글을 달려면 로그인하십시오.

답변 (3개)

Artur M. G. Lourenço
Artur M. G. Lourenço 2013년 5월 26일
Try this,
figure;
A = loglog(1:50)
hold on
B = loglog(1:50)
C = loglog(1:50)
str = sprintf('3SRS - Run %d - Dir %d');
title(str);
xlabel('Fréquences [Hz]');
ylabel('Accel (G)');
legend( [A B C], 'Test A','Test B','Test C' );
filename = str;
saveas(figure(1),filename,'fig');
close figure 1
  댓글 수: 1
Olivier
Olivier 2013년 5월 26일
As I said above, the '...' are full filled with my data. It's a general scheme where I point out the problem that my legend isn't saved in the .fig figure.
Thanks if you can give me more explanations.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2013년 5월 26일
  댓글 수: 2
Olivier
Olivier 2013년 5월 26일
I'm sorry but i don't think it answers my question... Thanks, however.
Image Analyst
Image Analyst 2013년 5월 26일
export_fig (the most downloaded file from the File Exchange, and recommended by the FAQ) will save the entire figure or axes. I'd be surprised if saved everything except the legend.

댓글을 달려면 로그인하십시오.


Adam Neuf
Adam Neuf 2015년 5월 21일
I'm having the same problem, have you found the solution to fix this?

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by