-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathfig2print.m
42 lines (38 loc) · 1.14 KB
/
fig2print.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
function fig2print(fignrs,oren)
% FIG2PRINT(fignrs,oren)
%
% Makes the figure window WYSIWYG.
% Also works on a vector of figure numbers
%
% Tested on 8.3.0.532 (R2014a)
%
% Last modified by fjsimons-at-alum.mit.edu, 05/22/2019
defval('fignrs',gcf)
defval('fignrs','portrait')
oren=lower(oren);
for index=1:length(fignrs)
fignr=fignrs(index);
switch oren
case { 'tall','landscape','portrait'}
orient(fignr,oren)
case { 'flandscape'};
pu=get(fignr,'PaperUnits');
set(fignr,'PaperUnits','normalized')
set(fignr,'Paperorientation','landscape','paperposition',[0 0 1 1]);
set(fignr,'PaperUnits',pu)
case { 'fportrait','ftall'}
pu=get(fignr,'Paperunits');
set(fignr,'PaperUnits','normalized')
set(fignr,'Paperorientation','portrait','paperposition',[0 0 1 1]);
set(fignr,'PaperUnits',pu)
otherwise
error('Illegal option');
end
ppos = get(fignr,'PaperPosition');
su = get(fignr,'Units');
pu = get(fignr,'PaperUnits');
set(fignr,'Units',pu);
spos = get(fignr,'Position');
set(fignr,'Position',[spos(1)-(ppos(3)-spos(3)) spos(2)-(ppos(4)-spos(4)) ppos(3) ppos(4)])
set(fignr,'Units',su)
end