matlab以⼦图形绘制,如何在MATLAB中的⼦图中对齐绘图图
形?
我有3个物体(⼀张照⽚和两个地块)放在⼀个图上的⼦图中.它应该如下所⽰:
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')
lol怎么玩
pos3=get(pion,'Position')
傅雷家书好句
pos1(3) = pos2(3); %width for the upper plot
t(poz,'Position',pos1)
pos3(4) = pos2(4); %height for the right plot
t(pion,'Position',pos3)
重力迷宫
我得到的就像这样:
如何强制上图具有照⽚本⾝的宽度(⽽不是照⽚⼦图)?设置⼦图的相等宽度不起作⽤,因为照⽚未填充⼦图区域.
最佳答案 命令轴图像调整图像轴⽐率.因此,原则上,如果您将两个地块的地积⽐率调整为相同的⽐率,它将按您的要求进⾏.
有⼀点需要注意;由于您将图形绘制在3×3⼦图中,⽽顶部为1×3,右图为3×1,因此图像本质上⽐图的宽3倍或更⾼.因此,您必须将图表的x或y⽐率除以3.
⼀些⽰例代码:更年期饮食
clc, clf
% generate some bogus data
ypion = rand(500,1);
Ppion = 450*rand(500,1);
xpoz = rand(500,1);
Ppoz = 450*rand(500,1);
% Load photo
photoSub = subplot(4,4,[5,6,7,9,10,11,13,14,15]);
load mandrill
photo = imagesc([X,X]);
colormap(map)
axis image
photoAxs = gca;
photoAxsRatio = get(photoAxs,'PlotBoxAspectRatio')汉语的魅力
% right plot
subplot(4,4,[8,12,16]);
刘子羽
plot(Ppion,ypion,'k.');
rightAxs = gca;
axis tight
雷峰图片% upper plot
subplot(4,4,[1 2 3]);
plot(xpoz,Ppoz,'k.');
topAxs = gca;
axis tight
% adjust ratios
topAxsRatio = photoAxsRatio;
topAxsRatio(2) = photoAxsRatio(2)/3.8; % NOTE: not
t(topAxs,'PlotBoxAspectRatio', topAxsRatio)
rightAxsRatio = photoAxsRatio;
rightAxsRatio(1) = photoAxsRatio(1)/3.6; % NOTE: not
电话卡注销t(rightAxs,'PlotBoxAspectRatio', rightAxsRatio)
这给出了以下结果:
只是为了测试,改变photo = imagesc([X,X]); to photo = imagesc([X; X]);给出这个:
请注意,我没有将⽐率精确地除以3;如果我使⽤接近4的因⼦,它才会出来.我不知道为什么会这样; AFAIK,3倍应该可以解决问题……哦,好吧,⾄少你现在有办法了:)