function [x_str, y_str] = bfitdatastatsetup(fighandle,datahandle)
% BFITDATASTATSETUP setup appdata for data set in Data Statistics GUI.

%   Copyright 1984-2000 The MathWorks, Inc. 
%   $Revision: 1.5 $  $Date: 2000/05/22 01:47:28 $

infarray = repmat(inf,1,5);
axesH = get(datahandle,'parent');

% for this axes, store it in the appdata of the fighandle: sharing with Basic Fit
axeshandles = getappdata(fighandle,'_Basic_Fit_Axes_Handles'); 
if isempty(axeshandles) | ~any(axesH == axeshandles)
    axeshandles(end + 1) = axesH;
    setappdata(fighandle,'_Basic_Fit_Axes_Handles', axeshandles);
end

% for this data set, store it in the appdata of the figure
datasethandles = getappdata(fighandle,'_Data_Stats_Data_Handles'); 
if isempty(datasethandles) | ~any(datahandle == datasethandles)
    datasethandles(end + 1) = datahandle;
    setappdata(fighandle,'_Data_Stats_Data_Handles', datasethandles);
end
setappdata(fighandle,'_Data_Stats_Current_Data',datahandle);

% place to store stats
setappdata(datahandle,'_Data_Stats_X',[]);
setappdata(datahandle,'_Data_Stats_Y',[]);

% place to store handles of lines plotted, and
% index vector of who is currently plotted
setappdata(datahandle,'_Data_Stats_X_Handles',infarray);  % array of handles of plots
setappdata(datahandle,'_Data_Stats_Y_Handles',infarray);  % array of handles of plots
setappdata(datahandle,'_Data_Stats_X_Showing', logical(zeros(1,5))); % array of logicals: 1 if showing
setappdata(datahandle,'_Data_Stats_Y_Showing', logical(zeros(1,5))); % array of logicals: 1 if showing

% Add the data to the legend and put note that this is data
statappdata.type = 'data';
statappdata.index = [];
setappdata(datahandle,'_bfit',statappdata);

bfitcreatelegend(axesH);
% compute data stats to return
[x_str, y_str] = bfitcomputedatastats(datahandle);

