Home > atmlab > graphs > scale_fig.m

scale_fig

PURPOSE ^

SCALE_FIG Resizes a figure and the text size.

SYNOPSIS ^

function scale_fig(scfac)

DESCRIPTION ^

 SCALE_FIG   Resizes a figure and the text size.

    The function changes the size of the current figure with the given 
    scaling factor.

    The same scaling is applied vertically and horisontally. The scaling
    is further applied on all text objects. 

    The idea is that a figure could be given any size maintaining the same
    relative appearence. This works for re-scaling with factors not deviating
    too much from 1, but as the space between e.g. axes and labels is not
    scaled in the same way by Matlab (which is done automatically), larger
    size changes distorts the appearence of the figure. For example, if a 
    larger figure is made small it is a risk that axes labels will be moved
    outside the figure, despite that the font size is made small.

 FORMAT   scale_fig(scfac)
        
 IN    scfac   Scaling factor (1 results in no effective scaling).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

scale_fig.m

SOURCE CODE ^

0001 % SCALE_FIG   Resizes a figure and the text size.
0002 %
0003 %    The function changes the size of the current figure with the given
0004 %    scaling factor.
0005 %
0006 %    The same scaling is applied vertically and horisontally. The scaling
0007 %    is further applied on all text objects.
0008 %
0009 %    The idea is that a figure could be given any size maintaining the same
0010 %    relative appearence. This works for re-scaling with factors not deviating
0011 %    too much from 1, but as the space between e.g. axes and labels is not
0012 %    scaled in the same way by Matlab (which is done automatically), larger
0013 %    size changes distorts the appearence of the figure. For example, if a
0014 %    larger figure is made small it is a risk that axes labels will be moved
0015 %    outside the figure, despite that the font size is made small.
0016 %
0017 % FORMAT   scale_fig(scfac)
0018 %
0019 % IN    scfac   Scaling factor (1 results in no effective scaling).
0020 
0021 
0022 % 2002-12-12   Created by Patrick Eriksson.
0023 
0024 
0025 function scale_fig(scfac)
0026 
0027 
0028 %=== Check input
0029 %
0030 rqre_nargin( 1, nargin );
0031 %
0032 if ~isscalar( scfac )  |  scfac <= 0
0033   error('The scaling factor must be a scalar >= 0.');
0034 end
0035 
0036 
0037 %=== Get figure position
0038 %
0039 h = gcf;
0040 %
0041 pos = get( h, 'Position' );
0042 
0043 
0044 %=== Re-size without moving centre point
0045 %
0046 dx = ( scfac - 1 ) * pos(3);
0047 dy = ( scfac - 1 ) * pos(4);
0048 %
0049 set( h, 'Position', [pos(1)-dx/2 pos(2)-dy/2 pos(3)+dx pos(4)+dy] );
0050 
0051 
0052 %=== Scale text
0053 %
0054 scale_text( h, scfac );

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005