How can I insert 2 figures in one figure?
Show older comments
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!
Accepted Answer
More Answers (1)
Cong Ba
on 24 Jul 2017
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 Comments
Agustin
on 26 Jul 2017
Chad Greene
on 26 Jul 2017
Agustin, in cases like this you'll usually have better luck starting a new question because a lot of folks on the forum only check the questions that don't have any answers yet. But I think I can answer your question.
There are a couple of ways you can go about this. One way is to put the colorbar inside the axis limits by specifying the location as 'north', 'south', 'east', or 'west'. Like this:
figure
subplot(1,2,1)
imagesc(peaks)
subplot(1,2,2)
imagesc(peaks)
colorbar('north')
Or you can set the position of the axes manually like this:
figure
subplot(1,2,1)
imagesc(peaks)
subplot(1,2,2)
imagesc(peaks)
% get axis position:
axpos = get(gca,'pos');
% Call a colorbar:
cb = colorbar;
% reset axis position:
set(gca,'pos',axpos)
Agustin
on 27 Jul 2017
Agustin
on 27 Jul 2017
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!