How do I merge two figures into one?

조회 수: 10 (최근 30일)
Janna Hinchliff
Janna Hinchliff 2021년 12월 13일
답변: Johannes Hougaard 2021년 12월 13일
I have two separate figures plotted and I want to make them into a single figure. I don't just want two separate figures in the same figure window, I want the lines that are plotted in one figure to be transferred to the other, all on the same set of axes. Is it possible to do this after creating the figure? I'm including the figures I want to merge and an example of how it should look after (I don't have access to the code that does what I want it to do).
I want to merge this:
and this:
to get something like this:
Is there a way to do this?
  댓글 수: 1
KSSV
KSSV 2021년 12월 13일
Red about findobj. From here get coordinates and plot on the other figure.

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

답변 (1개)

Johannes Hougaard
Johannes Hougaard 2021년 12월 13일
This code will do something like what you wish, but you'll have to adapt it to your own data
x_values = linspace(0,8*pi,1234);
fh = figure;
hold on
for ii = 1:3
plot(x_values,abs(sin(x_values)*rand*60));
end
gh = figure;
hold on
for ii = 1:4
plot(x_values,abs(cos(x_values)*rand*60));
end
lh1 = findall(fh,'type','line');
lh2 = findall(gh,'type','line');
nf = figure;
axes;
copyobj(lh1,nf.CurrentAxes);
copyobj(lh2,nf.CurrentAxes);

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by