-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcpsTileFigs.m
More file actions
60 lines (53 loc) · 1.87 KB
/
cpsTileFigs.m
File metadata and controls
60 lines (53 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
function figs=cpsTileFigs(figs)
%cpsTileFigs Tile all open figure windows on the screen
% cpsTileFigs places all open figure windows around on the screen with no
% overlap.
%
% This function is based on 'tilefigs' by Peter J. Acklam (2003).
%
% Part of <a href="matlab:help cpsPlotTools">cpsPlotTools</a>.
%
% Copyright 2003 Peter J. Acklam, 2016 Jacob Duijnhouwer
if nargin==0
figs = findobj('Type', 'Figure'); % ...find all figures.
figs = sort(figs);
end
if isempty(figs)
disp('No open figures or no figures specified.');
return
end
horSpc = 0.00; % Horizontal space.
topSpc = 0.00; % Space above top figure.
verSpc = 0.00; % Space between figures.
botSpc = 0.05; % Space below bottom figure.
units = 'normalized';
% Set miscellaneous parameter
nFigs = numel(figs);
nHor = ceil(sqrt(nFigs));
nVer = ceil(nFigs/nHor);
% Get the screen size.
oldRootUnits = get(0,'Units');
set(0,'Units',units);
scrdim = get(0,'ScreenSize');
set(0,'Units',oldRootUnits);
scrWid = scrdim(3);
scrHei = scrdim(4);
figWid = (scrWid-(nHor+1)*horSpc)/nHor;
figHei = (scrHei-(topSpc+botSpc)-(nVer-1)*verSpc)/nVer;
% Put the figures where they belong.
for row = 1:nVer
for col = 1:nHor
idx = (row-1)*nHor+col;
if idx<=nFigs
figLft = col*horSpc+(col-1)*figWid;
figBot = scrHei-topSpc-row*figHei-(row-1)*verSpc;
figPos = [figLft figBot figWid figHei];
oldFigUnits = get(figs(idx),'Units');
set(figs(idx),'Units',units);
set(figs(idx),'OuterPosition',figPos);
set(figs(idx),'Units',oldFigUnits);
figure(figs(idx)); % Raise figure.
end
end
end
end