Home > atmlab > graphs > scale_text.m

scale_text

PURPOSE ^

SCALE_TEXT Scales the text size of a figure or objects with a factor.

SYNOPSIS ^

function scale_text(h,scfac)

DESCRIPTION ^

 SCALE_TEXT   Scales the text size of a figure or objects with a factor.

    The function scales all text objects with the given scalimng factor.
    The scaling is applied to the given handles and their childrens (all
    generations, see *children*). To make all text objects 20% in a figure:
       scale_text( gcf, 1.2 );

 FORMAT   scale_text(h,scfac)
        
 IN    h       Handle to the figure, or figure objects.
       scfac   Scaling factor (1 results in no effective scaling).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

scale_text.m

SOURCE CODE ^

0001 % SCALE_TEXT   Scales the text size of a figure or objects with a factor.
0002 %
0003 %    The function scales all text objects with the given scalimng factor.
0004 %    The scaling is applied to the given handles and their childrens (all
0005 %    generations, see *children*). To make all text objects 20% in a figure:
0006 %       scale_text( gcf, 1.2 );
0007 %
0008 % FORMAT   scale_text(h,scfac)
0009 %
0010 % IN    h       Handle to the figure, or figure objects.
0011 %       scfac   Scaling factor (1 results in no effective scaling).
0012 
0013 % 2002-12-12   Created by Patrick Eriksson.
0014 
0015 
0016 function scale_text(h,scfac)
0017 
0018 
0019 %=== Check input
0020 %
0021 rqre_nargin( 2, nargin );
0022 %
0023 if ~isvector( h )
0024   error('The argument *h* must be a numeric vector.');
0025 end
0026 %
0027 if ~isscalar( scfac )  |  scfac <= 0
0028   error('The scaling factor must be a scalar >= 0.');
0029 end
0030 
0031 
0032 %=== Append given handle(s) and children
0033 %
0034 h = [ h; children( h ) ];
0035 
0036 
0037 %=== Loop handles and scale all possible text
0038 %
0039 for ih = 1 : length( h )
0040 
0041   switch lower( get( h(ih), 'type' ) )
0042 
0043     case 'text'
0044       %
0045       fsize = get( h(ih), 'FontSize' );
0046       set( h(ih), 'FontSize', scfac*fsize );
0047 
0048     case 'axes'
0049       %
0050       fsize = get( h(ih), 'FontSize' );
0051       set( h(ih), 'FontSize', scfac*fsize );
0052       %
0053       hl = get( h(ih), 'Xlabel' );
0054       fsize = get( hl, 'FontSize' );
0055       set( hl, 'FontSize', scfac*fsize );
0056       %
0057       hl = get( h(ih), 'Ylabel' );
0058       fsize = get( hl, 'FontSize' );
0059       set( hl, 'FontSize', scfac*fsize );
0060       %
0061       hl = get( h(ih), 'Zlabel' );
0062       fsize = get( hl, 'FontSize' );
0063       set( hl, 'FontSize', scfac*fsize );
0064       %
0065       hl = get( h(ih), 'Title' );
0066       fsize = get( hl, 'FontSize' );
0067       set( hl, 'FontSize', scfac*fsize );
0068 
0069   end
0070 end

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