@@ -22,8 +22,17 @@ function figuresize( varargin )
22
22
% as well as 'mm', 'cm', 'in', or 'pt'. Default 'cm'.
23
23
%
24
24
% figuresize(w,h,u,padscale)
25
- % - Use <padscale> to adjust (can be given as a single element or
26
- % two-element vector for width/height separately). Default 0.01.
25
+ % - Use <padscale> to adjust normalised padding added to the sides.
26
+ % Can be 1, 2, or 4 element vector:
27
+ % padscale = s % add s*w to the left/right and
28
+ % s*h to the top/bottom
29
+ % padscale = [sw sh] % add sw*w to the left/right and
30
+ % sh*h to the top/bottom
31
+ % padscale = [sl sr st sb] % add sl*w to the left, sr*w to the right,
32
+ % st*h to the top, and sb*h to the bottom
33
+ % Default [0 0 0 0.1] -- add some padding at bottom only due to a
34
+ % longstanding limitation of how Matlab produces PDFs at small physical
35
+ % sizes, where "small" is approx <10cm in height.
27
36
28
37
29
38
if numel(varargin ) == 0
@@ -32,7 +41,7 @@ function figuresize( varargin )
32
41
end
33
42
34
43
if numel(varargin ) == 1
35
- figure(varargin{: }); clf ; hold on
44
+ figure(varargin{: }); clf ; hold on ; box on
36
45
figuresize();
37
46
return
38
47
end
@@ -44,16 +53,18 @@ function figuresize( varargin )
44
53
p .addRequired(' height' ,@(x ) isnumeric(x ) && all(size(x )==1 ) );
45
54
p .addOptional(' units' ,' centimeters' ,...
46
55
@(x ) any(strcmpi(x ,allowed_units )) );
47
- p .addOptional(' padscale' ,0.01 , @(x ) isnumeric(x ) )
56
+ p .addOptional(' padscale' ,[ 0.0 0.0 0.0 0.1 ] , @(x ) isnumeric(x ) )
48
57
49
58
p .parse( varargin{: } );
50
59
w = p .Results .width ;
51
60
h = p .Results .height ;
52
61
u = p .Results .units ;
53
62
s = p .Results .padscale ;
54
63
55
- if numel(s ) == 1
56
- s = [s s ];
64
+ switch numel(s )
65
+ case 1 , s = [s s s s ];
66
+ case 2 , s = [s(1 ) s(1 ) s(2 ) s(2 )];
67
+ case 3 , error(' 1, 2, or 4 elements only' );
57
68
end
58
69
59
70
switch u
@@ -69,8 +80,8 @@ function figuresize( varargin )
69
80
set(gcf ,...
70
81
' Position' ,[screenpos(1 : 2 ) w h ],...
71
82
' PaperUnits' ,u ,...
72
- ' PaperPosition' ,[s(1 )*w s(2 )*h w h ],...
73
- ' PaperSize' ,[w *(1 + 2 * s(1 )) h *(1 + 2 * s( 2 ))]);
83
+ ' PaperPosition' ,[s(1 )*w s(4 )*h w h ],...
84
+ ' PaperSize' ,[w *(1 + s(1 )+s( 2 )) h *(1 + s( 3 )+s( 4 ))]);
74
85
75
86
end
76
87
@@ -98,4 +109,4 @@ function figuresize( varargin )
98
109
% LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
99
110
% ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
100
111
% (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
101
- % THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
112
+ % THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0 commit comments