[英]Stop overlapping figures in Octave
有没有一种简单的方法可以让多个数字在显示器上均匀分布而无需手动调整?
我尝试使用autoArrangeFigures Matlab 社区功能,但运气不佳。 首先,我遇到了各种脚本错误,一旦解决,它就无法阻止 Linux(pop-os)环境中的重叠数字。
下面是我称为tilefig
的函数,它仅在工具栏上重叠图块,即最大化绘图可见性。 在 MATLAB 中进行了测试,但我对一些不太常见的函数(如allchild(0)
和get(0,'screensize')
进行了一些快速文档检查,我认为它应该与 Octave 兼容。
我已经评论了代码,但基本上逻辑是
在没有输入的情况下运行tilefig
将从左上角的当前图形开始平铺整个屏幕。
为了使平铺整齐,它还将所有图形的大小调整为相同的宽度/高度。
带有 7 个数字的tilefig([],4)
的示例结果
function tilefig( maxrows, maxcols, p )
% Tile figures to max rows/cols in a grid, can be [] to just use all
% screen space. Optional input 'p' for top-left tile position, will use
% current figure if omitted.
AllFig = allchild(0); % Get all figures
pScr = get(0, 'screensize'); % Get screen size
if nargin < 1 || isempty( maxrows )
maxrows = inf;
end
if nargin < 2 || isempty( maxcols )
maxcols = inf;
end
if nargin < 3
p = get( gcf, 'Position' );
end
pNew = p; % Current position
nr = 1; nc = 1; % Row/col numbers
for ii = 1:numel(AllFig)
if sum(pNew([1,3])) > pScr(3) || nc > maxcols
% Exceeded screen width or max num columns
nc = 1;
nr = nr + 1;
pNew(1) = p(1);
pNew(2) = pNew(2) - pNew(4);
end
if pNew(2) < 0 || nr > maxrows
% Loop back to the first row if exceeds screen height / max row
nr = 1;
pNew(2) = p(2);
end
set( AllFig(ii), 'Position', pNew );
nc = nc + 1;
pNew = pNew + [pNew(3), 0, 0, 0];
end
% Reverse the overlap
for ii = numel(AllFig):-1:1
figure( AllFig(ii) );
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.