Home > atmlab > graphs > set_figsize.m

set_figsize

PURPOSE ^

SET_FIGSIZE Sets the figure to a specified size.

SYNOPSIS ^

function set_figsize(width,height)

DESCRIPTION ^

 SET_FIGSIZE   Sets the figure to a specified size.

    The size is applied to both screen and paper version. The size refers
    to the complete size (not the size of the axes area).

 FORMAT   set_figsize(width,height)
        
 IN    width   Width of figure in mm.
       height  Height of figure in mm.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

set_figsize.m

SOURCE CODE ^

0001 % SET_FIGSIZE   Sets the figure to a specified size.
0002 %
0003 %    The size is applied to both screen and paper version. The size refers
0004 %    to the complete size (not the size of the axes area).
0005 %
0006 % FORMAT   set_figsize(width,height)
0007 %
0008 % IN    width   Width of figure in mm.
0009 %       height  Height of figure in mm.
0010 
0011 % 2006-04-06   Created by Patrick Eriksson.
0012 
0013 
0014 function set_figsize(width,height)
0015 
0016 
0017 %=== Basic check of input
0018 %
0019 rqre_nargin( 2, nargin );
0020 
0021 
0022 %=== Store present units
0023 %
0024 h = gcf;
0025 %
0026 unit1 = get( h, 'Unit' );
0027 unit2 = get( h, 'PaperUnit' );
0028 
0029 
0030 %=== Set unit cm
0031 %
0032 set( h, 'Unit', 'ce' );
0033 set( h, 'PaperUnit', 'ce' );
0034 
0035 
0036 %=== Scale set lengths
0037 %
0038 width   = width / 10;
0039 height  = height / 10;
0040 
0041 
0042 %= Get current positions
0043 %
0044 pos1 = get( h, 'Position' );
0045 pos2 = get( h, 'PaperPosition' );
0046 
0047 
0048 %=== Set positions
0049 %
0050 set( h, 'Position', ...
0051         [pos1(1)+pos1(3)/2-width/2 pos1(2)+pos1(4)/2-height/2 width height] );
0052 set( h, 'PaperPosition', ...
0053         [pos2(1)+pos2(3)/2-width/2 pos2(2)+pos2(4)/2-height/2 width height] );
0054 
0055 
0056 %=== Re-set units
0057 set( h, 'Unit', unit1 );
0058 set( h, 'PaperUnit', unit2 );

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