-
Notifications
You must be signed in to change notification settings - Fork 0
/
combineFigs.m
62 lines (54 loc) · 1.47 KB
/
combineFigs.m
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
61
62
function combineFigs(figs,rows,cols,orientation)
% combineFigs Combine a set of figure windows into a single figure
%
% combineFigs(figs,rows,cols, [orientation])
%
% note, only works with a single axis in each figure to be combined
%
% optional params are same as for jisubplot & are passed directly
% default orientation is 'portrait'
% prop/value pairs are applied to copied axes
%
% JRI
if nargin==0
help combineFigs
return
end
if nargin == 3,
orientation = 'portrait';
end
%properties to apply to destination axes
axisArgs = {'fontsize',8};
%setup new figure
figure
jisubplot(rows,cols,0,orientation,[.2 .2],axisArgs{:})
finalFig = gcf;
for fig = figs,
figure(finalFig)
nextplot
destinationAxis = gca;
%grab some positional params of destination, then delete (making it ineligible for future subplotting)
destPos = get(destinationAxis,'position');
delete(destinationAxis)
figure(fig)
sourceAxis = get(fig,'Children');
%don't copy over adornments (which have tags)
sa = findobj(gcf,'tag','','type','axes');
if ~isempty(sa),
sa = sa(1);
else
sa = get(gcf,'children');
ignore = findobj(gcf,'type','uimenu');
sa = setdiff(sa,ignore);
end
newAx = copyobj(sa,finalFig);
axes(newAx)
set(newAx,'position',destPos,axisArgs{:});
% axes(sa)
% contents = get(sa,'children');
% limits = axis;
% h = copyobj(contents,destinationAxis);
% axes(destinationAxis)
% axis(limits)
hold on
end