function plotdisplay(iaxes)
%
%   Name: plotdisplay
%
%   Usage: plotdisplay(iaxes) 
%
%   Description: Plots the plot vectors in DISPLAY using the
%      parameters in DISPLAY under the axis number 'iaxes'
%     
%   Global Variables:
%      DISPLAY
%
%
%   Version SWD970727
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally     %
% developed as part of "DIAMOND" at          %
% Los Alamos National Laboratory. It may     %
% be copied, modified, and distributed in    %
% any form, provided:                        %
%  a) This notice accompanies the files and  %
%     appears near the top of all source     %
%     code files.                            %
%  b) No payment or commercial services are  %
%     received in exchange for the code.     %
%                                            %
% Original copyright is reserved by the      %
% Regents of the University of California,   %
% in addition to Scott W. Doebling, Phillip  %
% J. Cornwell, Erik G. Straser, and Charles  %
% R. Farrar.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%   Access required Global Variables

global DISPLAY indsvec

%   Extract the handle of the plot axis

haxes = DISPLAY{iaxes}.haxes;

axes(haxes)

%   Clear out the existing plots in this axis

set(haxes,'nextplot','replace')

%   Determine indices of xvector which will be plotted

xvec = DISPLAY{iaxes}.xvec;
dx = (max(xvec) - min(xvec)) / (length(xvec)-1);

%   Correct the axis limits if necessary

if DISPLAY{iaxes}.xlim(1) < min(xvec),
   DISPLAY{iaxes}.xlim(1) = min(xvec);
end

if DISPLAY{iaxes}.xlim(2) > max(xvec),
   DISPLAY{iaxes}.xlim(2) = max(xvec);
end

i1 = floor(DISPLAY{iaxes}.xlim(1)/dx) + 1;
i2 = floor(DISPLAY{iaxes}.xlim(2)/dx) + 1;

%   Define initial values for ylim

ylim = [inf -inf];

%   Loop over the plots to display in this axis

for inds = indsvec,
   
   %  Make the data plot
   
   DISPLAY{iaxes}.hline{inds} = plot(DISPLAY{iaxes}.xvec,DISPLAY{iaxes}.displayvec{inds});
   
   %  Set line, marker and color properties
   
   set(DISPLAY{iaxes}.hline{inds},'linestyle',DISPLAY{iaxes}.lnst{inds})
   set(DISPLAY{iaxes}.hline{inds},'color',DISPLAY{iaxes}.lnco{inds})
   set(DISPLAY{iaxes}.hline{inds},'marker',DISPLAY{iaxes}.marker{inds})
   
   %  Set the y-axis limits
   
   ylim = [0.98*min(ylim(1),min(DISPLAY{iaxes}.displayvec{inds}(i1:i2))) 1.02*max(ylim(2),max(DISPLAY{iaxes}.displayvec{inds}(i1:i2)))];

   set(haxes,'ylim',ylim) 
   
   %  Set the axis labels
   
   xlabel('Freq (Hz)')
   ylabel(DISPLAY{iaxes}.iyscale)

   %  Set the axes so that the next plot will add to the axes
   
   set(haxes,'nextplot','add')

end

%  Set to logarithmic scale if appropriate   

switch DISPLAY{iaxes}.iylog
   case 0, set(haxes,'yscale','linear')
   case 1, set(haxes,'yscale','log')
end
   
%  Set the x axis limits   
   
set(haxes,'xlim',DISPLAY{iaxes}.xlim)

%  Define the y axis limits

DISPLAY{iaxes}.ylim = get(haxes,'ylim');

%     Set the plot title

title(['Spectral Function: ',DISPLAY{iaxes}.specfun{1},'   --   Display Function: ',DISPLAY{iaxes}.displayfun{1}])

%     Draw the cursor, if appropriate

if ~isempty(DISPLAY{iaxes}.hcursor),
   drawcursor
end
   
   
%
%   ALL DONE
%

return