如何调整子图的高度?

3

我有两个子图,我需要第一个子图的大小比第二个子图大,因为第二个子图是触发信号。我已经调整了大小并减小了子图之间的间距。但问题是,当我尝试增加第一个子图的高度时,它超出了图形。我已经尝试过很多方法,但找不到解决方法。以下是代码:

figure

x = (Messwerte.mste_w.value);
x = x';
%calculates the integral for all the values
t = cumtrapz(x);
subplot(9,1,1);
%plotting mste_w and its integral together
[ax,h1,h2] = plotyy(Messwerte.(Messwerte.mste_w.time),...
Messwerte.mste_w.value,Messwerte.(Messwerte.mste_w.time),t,@area,@plot);

set(h1, 'FaceColor', 'g','LineWidth', 2);
set(h2, 'LineWidth', 2);
set(gca,'ButtonDownFcn','selectmoveresize');
set(gcf,'WindowButtonDownFcn','selectmoveresize');
A = get(gca,'position');
A_diff = 1.5*A(4);             
A(4) = A(4) + A_diff;
A(2) = A(2)-0.15*A(2) ;
set(gca,'position',A);
%set(ax(1),'xtick',[0:500:2000])
set(ax(1),'ylim',[0 7],'ytick',[0:1:7])
%set(ax(2),'xtick',[0:500:2000])
set(ax(2),'ylim',[0 70000],'ytick',[0:10000:70000])
axes(ax(1)); ylabel('mste-w','color','k');
axes(ax(2)); ylabel('Spülvolumen in miliLiter');
%xlabel('time[s]')
set(ax(1),'YColor', 'k');
set(ax(2),'YColor', 'k');
grid on
% title('FTP75 AKB beladen')


subplot(9,1,2);
plot(Messwerte.(Messwerte.B_te.time),Messwerte.B_te.value);
A = get(gca,'position');

% A(1,4) = 2*A(1,4) / 3 ;             % reduce the height by one third
% A(1,2) = A(1,2) - 0.1*A(1,4);         % change the vertical position

A_diff = A(4)/3;
A(4)=A(4)-A_diff;
A(2)=A(2)-0.5*A_diff;
set(gca,'position',A);
area(Messwerte.(Messwerte.B_te.time),Messwerte.B_te.value,...
    'FaceColor','g');
set(gca,'xtick',[0:500:2000]);
set(gca,'ytick',[]);
ylabel('B-te');
1个回答

1
所以,据我所理解,您有两个子图,共占图像高度的2/9,并且希望将第二个子图的大小减小到默认值的2/3,并将第一个子图的大小增加到默认值的4/3。
因此,我们希望第一个子图为高度的(4/3)x(1/9)=4/27,第二个子图为高度的(2/3)x(1/9)=2/27。最简单的方法是:
subplot(27,1,1:4);
% plot first figure
subplot(27,1,5:6);
% plot second figure

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接