function pdffplot
%
%  Name:   pdffplot
%
%  Usage:  pdffplot
%
%  Run the pdff plotting functions
% 

%  Version SWD970808
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%

global HANDLES DISPLAY DATA

%  Plot the time data in the first axes


iresp = DISPLAY{1}.iresp{1};
iref = DISPLAY{1}.iref{1};
iavg = DISPLAY{1}.iavg{1};
idf = DISPLAY{1}.idatafile{1};
t0 = DATA{idf}.t0;
t1 = DATA{idf}.t1;   
ntim = size(DATA{idf}.thist,1);
DISPLAY{1}.xvec = linspace(t0,t1 - (t1-t0)/ntim,ntim);   

axes(DISPLAY{1}.haxes)
plot(DISPLAY{1}.xvec, DATA{idf}.thist(:,iresp,iref,iavg));
xlabel('Time (sec)')
title(['Time History - Resp. #',num2str(iresp),' - Ref. #',num2str(iref),' - Ensemble #',num2str(iavg)])

%  Compute the PDFF and plot it

[pdx,pdf,h,gx,gv]=pdff(DATA{DISPLAY{1}.idatafile{1}}.thist(:,iresp,iref,iavg));
[n,x] = hist(DATA{DISPLAY{1}.idatafile{1}}.thist(:,iresp,iref,iavg));

axes(DISPLAY{2}.haxes)
plot(pdx,pdf,gx,gv,x,n/sum(n))
legend('PDF Fit','Gaussian Fit','Histogram')
title('Probability Density Functions')

switch  DISPLAY{2}.iylog,
case 0, set(DISPLAY{2}.haxes,'yscale','linear')
case 1, set(DISPLAY{2}.haxes,'yscale','log')
end


return