How to combine pre-saved plots (.fig) into one figure?

조회 수: 7 (최근 30일)
Ismaeel
Ismaeel 2017년 9월 17일
댓글: Image Analyst 2017년 9월 18일
Hi, I have several pre-saved plots in format .fig and I want to combine them together with different colors. Any simple function or idea to deal with this? Thanks in advance

답변 (1개)

Image Analyst
Image Analyst 2017년 9월 17일
Why not use export_fig() and save them as PNG images, then you can use montage() to create an array of those images?
  댓글 수: 4
Ismaeel
Ismaeel 2017년 9월 17일
편집: Ismaeel 2017년 9월 17일
Thanks Image Analyst for your reply. Do you think my question is hard to understand? you have saved .fig files and you want them all combined in one figure, simple and plain. Anyway, open or openfig do not make them one, instead, open them in their own figures. I have solved the problem using the link:
https://www.mathworks.com/matlabcentral/answers/3901-merging-two-figures
This is how I solved for 5 figures: P1, P2 P3, P4, and P5.
figure(1) = openfig('P1.fig');
figure(2) = openfig('P2.fig');
figure(3) = openfig('P3.fig');
figure(4) = openfig('P4.fig');
figure(5) = openfig('P5.fig');
L3 = findobj(2,'type','line');
L4 = findobj(3,'type','line');
L5 = findobj(4,'type','line');
L6 = findobj(5,'type','line');
copyobj(L3,findobj(1,'type','axes'));
copyobj(L4,findobj(1,'type','axes'));
copyobj(L5,findobj(1,'type','axes'));
copyobj(L6,findobj(1,'type','axes'));
Thanks once again
Image Analyst
Image Analyst 2017년 9월 18일
Yes it wasn't clear. I'd thought you wanted to open them and "tile" them, like into quadrants.
I think rather than getting the lines out, you can get the data out of the axes with XData and then replot it. Maybe something like (untested):
f1 = openfig(filename1)
ax = gca;
x1 = ax.XData;
y1 = ax.YData;
plot(x1, y1, 'b-', 'LineWidth', 2);
and so on for the other figures to get x2, y2, x3, y3, etc.
Don't use figure as the name of a variable like you did because that's the name of an important built-in function. Call it myFigures or something instead of figure.

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

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by