【发布时间】:2013-03-26 08:18:57
【问题描述】:
我有 3 个对象(一张照片和 2 个图)要放入一个图的子图中。它应该是这样的:
但正如人们注意到的那样,照片不应该是方形的,而是矩形的。我试着这样做(在这里找到Matlab: How to align the axes of subplots when one of them contains a colorbar?):
main=subplot(4,4,[5,6,7,9,10,11,13,14,15]) %photo
imagesc(im);
axis('image')
pion=subplot(4,4,[8,12,16]); %right plot (rotated)
view(90, 90)
plot(ypion,Ppion,'.k');
poz=subplot(4,4,1:3); %upper plot
plot(xpoz,Ppoz,'.k');
pos1=get(poz,'Position')
pos2=get(main,'Position')
pos3=get(pion,'Position')
pos1(3) = pos2(3); %width for the upper plot
set(poz,'Position',pos1)
pos3(4) = pos2(4); %height for the right plot
set(pion,'Position',pos3)
我得到的是这样的:
如何强制上部图的宽度作为照片本身(而不是照片子图)?设置子图的等宽不起作用,因为照片没有填满子图区域。
【问题讨论】:
-
从 2020 年开始,使用
tiledlayout可能比使用subplot更容易。