Home > atmlab > graphs > scale_axes.m

scale_axes

PURPOSE ^

SCALE_AXES Changes the size of a axes frame.

SYNOPSIS ^

function scale_axes(h,hscfac,vscfac)

DESCRIPTION ^

 SCALE_AXES   Changes the size of a axes frame.

    The function allows to change the size of a axes frame by giving
    a scaling factor for the horisontal and vertical directions. 

    A scaling factor of 1.2 means that the frame will be 20% larger in the
    direction of concern. For example, if *h* is a handle to a legend
    that you want to make broader, execure:
       scale_axes( h, 1.2 );

    Vertical scaling of legends can result in that plotting symbols and text
    are not aligned.

    The centre point of the axes will be not be moved.

 FORMAT   scale_axes(h,hscfac[,vscfac])
        
 IN    h        Handle to the legend.
       hscfac   Horisontal scaling factor.
 OPT   vscfac   Vertical scaling factor. Default is 1.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

scale_axes.m

SOURCE CODE ^

0001 % SCALE_AXES   Changes the size of a axes frame.
0002 %
0003 %    The function allows to change the size of a axes frame by giving
0004 %    a scaling factor for the horisontal and vertical directions.
0005 %
0006 %    A scaling factor of 1.2 means that the frame will be 20% larger in the
0007 %    direction of concern. For example, if *h* is a handle to a legend
0008 %    that you want to make broader, execure:
0009 %       scale_axes( h, 1.2 );
0010 %
0011 %    Vertical scaling of legends can result in that plotting symbols and text
0012 %    are not aligned.
0013 %
0014 %    The centre point of the axes will be not be moved.
0015 %
0016 % FORMAT   scale_axes(h,hscfac[,vscfac])
0017 %
0018 % IN    h        Handle to the legend.
0019 %       hscfac   Horisontal scaling factor.
0020 % OPT   vscfac   Vertical scaling factor. Default is 1.
0021 
0022 % 2002-12-12   Created by Patrick Eriksson.
0023 
0024 
0025 function scale_axes(h,hscfac,vscfac)
0026 
0027 
0028 %=== Check input and defaults
0029 %
0030 rqre_nargin( 2, nargin );
0031 %
0032 if ~isscalar( hscfac )  |  hscfac <= 0
0033   error('The horisonal scaling factor must be a scalar >= 0.');
0034 end
0035 %
0036 if nargin < 3
0037   vscfac = 1;
0038 else
0039   if ~isscalar( vscfac )  |  vscfac <= 0
0040     error('The vertical scaling factor must be a scalar >= 0.');
0041   end
0042 end
0043 
0044 
0045 pos = get( h, 'position' );
0046 
0047 
0048 dx = (hscfac-1) * pos(3);
0049 dy = (vscfac-1) * pos(4);
0050 
0051 set( h, 'position', [pos(1)-dx/2 pos(2)-dy/2 pos(3)+dx pos(4)+dy] );

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