Home > wafo > misc > figtext.m

figtext

PURPOSE ^

Places text in figure window.

SYNOPSIS ^

H = figtext(x,y,T,x_unit,y_unit,x_justify,y_justify,varargin)

DESCRIPTION ^

  FIGTEXT Places text in figure window.
          Writes  T  at the point by  (x,y). The default coordinate
          system used is that of the current axis. Normalized coordinates
          are optional. Different coordinate systems for the x- and y-axis
          are also allowed.
 
   CALL:  H = figtext(x,y,T,x_unit,y_unit,x_justify,y_justify)
 
         H = handle to the line of text.
         x       = the x-coordinate of the text.
         y       = the y-coordinate of the text.
         T       = a string containing the text.
         
         x_unit,
         y_unit  = 'data'   same coordinate system as the plotted data (default).
                   'norm'   use 'normalized' coordinates in [0..1].
       x_justify = 'left'   places left adjusted text (default).
                   'center' places centered text.
                   'right'  places right adjusted text.
 
       y_justify = 'top'    places top adjusted text 
                   'middle' places centered text. (default).
                   'bottom' places bottom adjusted text.
 
   Example: 
        H =  figtext(0,0,'test','norm',[],'left','top')
 
   See also  text

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

001 function H = figtext(x,y,T,x_unit,y_unit,x_justify,y_justify,varargin)
002 % FIGTEXT Places text in figure window.
003 %         Writes  T  at the point by  (x,y). The default coordinate
004 %         system used is that of the current axis. Normalized coordinates
005 %         are optional. Different coordinate systems for the x- and y-axis
006 %         are also allowed.
007 %
008 %  CALL:  H = figtext(x,y,T,x_unit,y_unit,x_justify,y_justify)
009 %
010 %        H = handle to the line of text.
011 %        x       = the x-coordinate of the text.
012 %        y       = the y-coordinate of the text.
013 %        T       = a string containing the text.
014 %        
015 %        x_unit,
016 %        y_unit  = 'data'   same coordinate system as the plotted data (default).
017 %                  'norm'   use 'normalized' coordinates in [0..1].
018 %      x_justify = 'left'   places left adjusted text (default).
019 %                  'center' places centered text.
020 %                  'right'  places right adjusted text.
021 %
022 %      y_justify = 'top'    places top adjusted text 
023 %                  'middle' places centered text. (default).
024 %                  'bottom' places bottom adjusted text.
025 %
026 %  Example: 
027 %       H =  figtext(0,0,'test','norm',[],'left','top')
028 %
029 %  See also  text
030 
031 % Tested on: Matlab 5.3, 5.2, 5.1
032 % History;
033 % revised by pab 06.02.2000
034 %  added varargin
035 % revised by pab 11.08.99
036 % added y_justify
037 
038 if (nargin<7)|isempty(y_justify),
039   y_justify='middle';
040 end
041 
042 if (nargin<6)|isempty(x_justify),
043   x_justify='left';
044 end
045 if (nargin<4)|isempty(x_unit),
046   x_unit='data';
047 end
048 
049 if (nargin<5)|isempty(y_unit),
050   y_unit=x_unit;
051 end
052   
053 h=text('String',T);
054 set(h,'HorizontalAlignment',x_justify,'VerticalAlignment',y_justify);
055 unit=get(h,'Units');
056 
057 set(h,'Units',x_unit)
058 xy=get(h,'Position');
059 set(h,'Position',[x xy(2)])
060 
061 set(h,'Units',y_unit)
062 xy=get(h,'Position');
063 set(h,'Position',[xy(1) y])
064 
065 set(h,'Units',unit);
066 
067 nin=length(varargin);
068 if nin>0
069   set(h,varargin{:});
070 end
071 
072 if nargout>0
073   H=h;
074 end
075

Mathematical Statistics
Centre for Mathematical Sciences
Lund University with Lund Institute of Technology

Comments or corrections to the WAFO group


Generated on Thu 06-Oct-2005 02:21:16 for WAFO by m2html © 2003