필터 지우기
필터 지우기

How can I insert 2 figures in one figure?

조회 수: 61 (최근 30일)
Agustin
Agustin 2017년 7월 24일
댓글: Agustin 2017년 7월 27일
Hi! I'm working with radar images and I'm getting the interferogram and the coherence from each pair of images. I want to show the interferogram and the coherence maps in one figure. My figures are as follows:
pcolor(X,Y,interf);
shading flat;
grid on;
axis equal;
xlim([xmin xmax]);
ylim([ymin ymax]);
xlabel('x [m]');
ylabel('y [m]');
pcolor(X,Y,coh);
shading flat;
grid on;
axis equal;
xlim([xmin xmax]);
ylim([ymin ymax]);
xlabel('x [m]');
ylabel('y [m]');
I have tried using subplot but what I get is a blank figure and the coherence map in a new figure. Can somebody help me with this?
Thanks!

채택된 답변

Chad Greene
Chad Greene 2017년 7월 24일
How were you calling subplot? Did you do it like this?
figure
subplot(2,1,1)
pcolor(X,Y,interf);
shading flat;
grid on;
axis equal;
xlim([xmin xmax]);
ylim([ymin ymax]);
xlabel('x [m]');
ylabel('y [m]');
subplot(2,1,2)
pcolor(X,Y,coh);
shading flat;
grid on;
axis equal;
xlim([xmin xmax]);
ylim([ymin ymax]);
xlabel('x [m]');
ylabel('y [m]');
  댓글 수: 2
Chad Greene
Chad Greene 2017년 7월 24일
Also a helpful trick. These three lines:
axis equal;
xlim([xmin xmax]);
ylim([ymin ymax]);
can be replaced by
axis equal
axis tight
You can even combine the axis commands into one line:
axis equal tight
And it just so happens there's a command that's even shorter:
axis image
Agustin
Agustin 2017년 7월 26일
Thank you so much! This was very helpful.

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

추가 답변 (1개)

Cong Ba
Cong Ba 2017년 7월 24일
Hi Agustin,
It seems like you want to have 2 separately plots on one figure - and if this is the case, subplot should serve your purpose well.
You may use something like:
figure;
subplot 121;
# plot your stuff here in the 1st subplot
subplot 122;
# plot the other one
Or, if you have tried this and it didn't work, there may be bugs. Then could you upload the code you are using to plot?
  댓글 수: 4
Agustin
Agustin 2017년 7월 27일
Thanks!
Agustin
Agustin 2017년 7월 27일
The second method worked exactly as I wanted. Thank you so much!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by