Home > atmlab > graphs > tplot.m

tplot

PURPOSE ^

TPLOT Text plots.

SYNOPSIS ^

function tplot(h,col,s,fsize,fweight)

DESCRIPTION ^

 TPLOT Text plots.

    Creates plots just including text. The text can be written in columns.

    The plot is initialized by calling the function with the axes handle
    and number of columns to create. Text is then written from the top
    downwards, one row (per column) for each function call.

    An example:
      tplot( gca, 2 );
      tplot( gca, 1, 'A FANCY AND BOORING TITLE',14,'B');
      tplot( gca, 2, '',14,'B');
      tplot( gca, 1, 'Here is column 1.');
      tplot( gca, 1, 'Column 1 again.');
      tplot( gca, 2, 'Here is column 2.');

 FORMAT   tplot(h,col)  or  tplot(h,col,s[,fsize,fweight])
        
 IN    h         Handle to axes where to place the text.
       col       In first format case: Number of columns to create.
                 In second format case: The text is placed in this column.
       s         String to print.
 OPT   fsize     Font size. Default is 12.
       fweight   Font weight. Default is 'n' (normal). For bold font: 'b'.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

tplot.m

SOURCE CODE ^

0001 % TPLOT Text plots.
0002 %
0003 %    Creates plots just including text. The text can be written in columns.
0004 %
0005 %    The plot is initialized by calling the function with the axes handle
0006 %    and number of columns to create. Text is then written from the top
0007 %    downwards, one row (per column) for each function call.
0008 %
0009 %    An example:
0010 %      tplot( gca, 2 );
0011 %      tplot( gca, 1, 'A FANCY AND BOORING TITLE',14,'B');
0012 %      tplot( gca, 2, '',14,'B');
0013 %      tplot( gca, 1, 'Here is column 1.');
0014 %      tplot( gca, 1, 'Column 1 again.');
0015 %      tplot( gca, 2, 'Here is column 2.');
0016 %
0017 % FORMAT   tplot(h,col)  or  tplot(h,col,s[,fsize,fweight])
0018 %
0019 % IN    h         Handle to axes where to place the text.
0020 %       col       In first format case: Number of columns to create.
0021 %                 In second format case: The text is placed in this column.
0022 %       s         String to print.
0023 % OPT   fsize     Font size. Default is 12.
0024 %       fweight   Font weight. Default is 'n' (normal). For bold font: 'b'.
0025 
0026 % 2002-12-14   Created by Patrick Eriksson.
0027 
0028 
0029 function tplot(h,col,s,fsize,fweight)
0030 
0031 
0032 %=== Input arguments
0033 %
0034 rqre_nargin( 2, nargin );
0035 %
0036 if ~iswhole(col)  |  col <= 0
0037   error('The argument *col* must be an integer > 0.');
0038 end
0039 %
0040 if nargin < 4
0041   fsize = 12;
0042 end
0043 %
0044 if nargin < 5
0045   fweight = 'n';
0046 end
0047 
0048 
0049 
0050 %=== Init the plot
0051 %
0052 if nargin < 3
0053   %
0054   h0 = gca;
0055   axes( h );
0056   cla;
0057   axes( h0 );
0058   %
0059   %- Turn off frame
0060   axes_frame( h, 'off' );
0061   %
0062   %- Set other values to store in UserData
0063   A.ncol = col;
0064   A.row  = repmat( 0.98, 1, col );  % y-position of lower part ot text per col
0065   %
0066   set( h, 'UserData', A );
0067 
0068 
0069 %=== Write text
0070 %
0071 else
0072   %
0073   A = get( h, 'UserData' );
0074   %
0075   if ~isfield( A, 'ncol' )
0076     error('It appears that the UserData of the axes are corrupted.');
0077   end
0078   %
0079   if col > A.ncol
0080     error( sprintf('You selected column %d, but only %d columns exist.', ...
0081                                                               col, A.ncol ) );
0082   end
0083   %
0084   %- Determine height of text in axes coordinates
0085   ht = text( 0.5, 0.5, 'T', 'FontSize', fsize, 'FontWeight', fweight );
0086   dummy = get( ht, 'Extent' );
0087   htext = dummy(4); 
0088   delete(ht);
0089   %
0090   x = 0.02 + 0.98 * (col -1) / A.ncol;
0091   y = A.row(col) - 0.6 * htext;
0092   %
0093   A.row(col) = y - htext/2;;
0094   %
0095   text( x, y, s, 'FontSize', fsize, 'FontWeight', fweight ); 
0096   %
0097   set( h, 'UserData', A );
0098 
0099 end

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