-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfigurebetter.m
102 lines (91 loc) · 2.45 KB
/
figurebetter.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
% Make a new figure without some of the usual Mathworks insanity.
% figsize is in cm and determines also the size of the 'paper'
% we also support a few shortcuts for sensible standard sizes:
% tiny: 4 should sideways on A4
% small: 3 fit
% medium: 2 fit
% large: 1 fits
% F is a handle number (defaults to uniquehandle output)
% F = figure([F],figsize,[axisar],[visible])
function F = figure(F,figsize,axisar,visible)
% This is a bit awkward but often we only want to enter a size argument
if nargin==1
figsize=F;
clear F
end
if ieNotDefined('F')
F = uniquehandle;
end
if ieNotDefined('figsize')
figsize = 'small';
end
if ieNotDefined('visible')
visible = get(0,'defaultfigurevisible');
end
% Hack to allow 1/0 true/false options
if ~isstr(visible)
if visible
visible = 'on';
else
visible = 'off';
end
end
a4 = [21 29.7];
% With a default figure aspect ratio
if isstr(figsize)
figar = 3/4;
switch lower(figsize)
case {'tiny'}
modifier = 1/4;
case {'small'}
modifier = 1/3;
case {'medium'}
modifier = 1/2;
case {'large'}
modifier = 1;
case {'huge'}
modifier = 1.5;
otherwise
error('unknown figsize: %s',figsize)
end
figsize = a4(1) .* [modifier modifier*figar];
end
axisararg = 'defaultaxesplotboxaspectratio';
if ieNotDefined('axisar')
axisar = figsize(2)/figsize(1);
end
if numel(axisar) < 3
axisar = [1 axisar 1];
end
if strcmp(axisar,'auto')
axisararg = [axisararg 'mode'];
end
iptsetpref('ImshowBorder','tight');
sysfonts = lower(listfonts);
if any(strcmp(sysfonts,'helvetica'))
fon = 'helvetica';
elseif any(strcmp(sysfonts,'arial'))
fon = 'arial';
else
error('Cannot find helvetica or arial on system')
end
F = figure(F);
set(F,'color',[1 1 1],... % white BG
'inverthardcopy','off',... % don't flip colours when printing
'paperunits','centimeters',... % size in CM
'papersize',figsize,... % paper=figsize
'paperposition',[0 0 figsize],... % figure insize paper
'units','centimeters',...
'position',[0 0 figsize],... % use same units for figure and paper
'defaultaxescolor',[1 1 1],... % white axes bg
'defaultlinelinewidth',1,...
'defaultaxesfontname',fon,...
'defaultaxesfontsize',7,...
'defaultuicontrolfontname',fon,...
'defaultuicontrolfontsize',7,...
'defaulttextfontname',fon,...
'defaulttextfontsize',7,...
'defaultaxeslooseinset',[0 0 0 0],... % kill whitespace!
'colormap',cmap_bwr,...
'visible',visible,...
axisararg,axisar);