필터 지우기
필터 지우기

Combining multiple MATLAB figures in one plot

조회 수: 228 (최근 30일)
Satish Jawalageri
Satish Jawalageri 2020년 8월 4일
편집: DGM 2024년 5월 4일
How can I merge the three different saved matlab figures (plots) in one graph?

답변 (2개)

Sourabh Kondapaka
Sourabh Kondapaka 2020년 8월 7일
Hi,
You can utilize “openfig()” for the purpose of opening a figure.
openfig()” by default opens the figure. The below approach shows how to merge 3 figures, but it also opens other individual figures themselves.
Here ‘fig1.fig’, ‘fig2.fig’ and ‘fig3.fig’ are 3 sample figures.
close all;
h(1) = openfig('fig1.fig');
h(2) = openfig('fig2.fig');
h(3) = openfig('fig3.fig');
hold on;
title('Final Merged Figure');
plot(h(1).Children.Children.XData, h(1).Children.Children.YData);
plot(h(2).Children.Children.XData, h(2).Children.Children.YData);
plot(h(3).Children.Children.XData, h(3).Children.Children.YData);
hold off;
If you do not want to see the plots of the individual figures, you can pass the parameter ‘invisible’ to “openfig()”.
close all;
h(1) = openfig('fig1.fig', 'invisible');
h(2) = openfig('fig2.fig', 'invisible');
h(3) = openfig('fig3.fig', 'invisible');
hold on;
k = gcf;
k.Visible = 'on';
title("Final Merged Figure");
plot(h(1).Children.Children.XData, h(1).Children.Children.YData);
plot(h(2).Children.Children.XData, h(2).Children.Children.YData);
plot(h(3).Children.Children.XData, h(3).Children.Children.YData);
hold off;
A similar question on accessing properties of a figure has been answered here
  댓글 수: 1
Araz Garaz
Araz Garaz 2022년 11월 25일
Hi,
I am trying to use your code but getting an error as
unrecognised method, property, or field 'XData' for class 'matlab.grapic.primitive.Data'.
Do you have any recomendation on that?

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


kefei
kefei 2022년 6월 22일
편집: DGM 2024년 5월 4일
you can use my figure2subplot.m function to copy each figure to one subplot in the target figure.
check this link for the function :

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by