在 Octave 中移动和调整子图的大小
Move and Resize Subplots in Octave
我想在 Octave 中移动和调整四个子图的大小,使它们更大,白色更少 space。下面的最小代码仅移动和调整第一个子图 (221) 的大小,同时保持其余三个不变。
sp_hand1 = subplot(221);plot(sinewave(20,20)) ;
set( sp_hand1 , 'OuterPosition' , [ -0.11 , 0.4 , 0.6 , 0.65 ] ) ;
sp_hand2 = subplot(222);plot(sinewave(20,20)) ;
set( sp_hand2 , 'OuterPosition' , [ -0.11 , 0.4 , 0.6 , 0.65 ] ) ;
sp_hand3 = subplot(223);plot(sinewave(20,20)) ;
set( sp_hand3 , 'OuterPosition' , [ -0.11 , 0 , 0.6 , 0.65 ] ) ;
sp_hand4 = subplot(224);plot(sinewave(20,20)) ;
set( sp_hand4 , 'OuterPosition' , [ -0.11 , 0 , 0.6 , 0.65 ] ) ;
如何将它们全部调整为相同大小并适当移动?
当我在论文中遇到类似问题时,我发现最适合我的解决方案是直接使用 axes
而不是子图,并指定 position
。一些手动调整在一开始可能是不可避免的,但它通常非常简单,并且可以很容易地自动化以实现可预测的图形放置,特别是如果图形大小也预先指定的话。
例如
h1 = axes('position', [0.04, 0.54, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
h2 = axes('position', [0.54, 0.54, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
h3 = axes('position', [0.04, 0.04, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
h4 = axes('position', [0.54, 0.04, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
理论上子图和独立轴的行为应该大致相同;最大的区别在于,在重叠的情况下,子图会删除重叠的图,而轴则愉快地重叠。这将包括 'invisible' 重叠。
我不是 100% 确定是否有办法使用 'outerposition' 获得相同的结果,但对我来说,外部定位的行为有点奇怪,而且我总是设法获得想要的结果直接用 'position',所以我从来不需要它。
我还发现,通常绘制更多内容或更改绘图的其他方面会重置某些坐标轴属性,因此此类大小调整最好作为每个坐标区对象的最后一步完成。
我想在 Octave 中移动和调整四个子图的大小,使它们更大,白色更少 space。下面的最小代码仅移动和调整第一个子图 (221) 的大小,同时保持其余三个不变。
sp_hand1 = subplot(221);plot(sinewave(20,20)) ;
set( sp_hand1 , 'OuterPosition' , [ -0.11 , 0.4 , 0.6 , 0.65 ] ) ;
sp_hand2 = subplot(222);plot(sinewave(20,20)) ;
set( sp_hand2 , 'OuterPosition' , [ -0.11 , 0.4 , 0.6 , 0.65 ] ) ;
sp_hand3 = subplot(223);plot(sinewave(20,20)) ;
set( sp_hand3 , 'OuterPosition' , [ -0.11 , 0 , 0.6 , 0.65 ] ) ;
sp_hand4 = subplot(224);plot(sinewave(20,20)) ;
set( sp_hand4 , 'OuterPosition' , [ -0.11 , 0 , 0.6 , 0.65 ] ) ;
如何将它们全部调整为相同大小并适当移动?
当我在论文中遇到类似问题时,我发现最适合我的解决方案是直接使用 axes
而不是子图,并指定 position
。一些手动调整在一开始可能是不可避免的,但它通常非常简单,并且可以很容易地自动化以实现可预测的图形放置,特别是如果图形大小也预先指定的话。
例如
h1 = axes('position', [0.04, 0.54, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
h2 = axes('position', [0.54, 0.54, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
h3 = axes('position', [0.04, 0.04, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
h4 = axes('position', [0.54, 0.04, 0.45, 0.45]); plot( sinewave( 20, 20 ) );
理论上子图和独立轴的行为应该大致相同;最大的区别在于,在重叠的情况下,子图会删除重叠的图,而轴则愉快地重叠。这将包括 'invisible' 重叠。
我不是 100% 确定是否有办法使用 'outerposition' 获得相同的结果,但对我来说,外部定位的行为有点奇怪,而且我总是设法获得想要的结果直接用 'position',所以我从来不需要它。
我还发现,通常绘制更多内容或更改绘图的其他方面会重置某些坐标轴属性,因此此类大小调整最好作为每个坐标区对象的最后一步完成。