function boxplotter(params,outsideValues,names)
% BOXPLOTTER - make box or whisker plots
%
%   boxplotter - make box or whisker plots
%  boxplotter(params,outliers,name)
%  params from boxparams.m
%  outsideValues from boxparams.m
%  name of the data series

% Copyright (c) 1998 by Datatool
% Revision: 1.00

% This function comes from http://datatool.com/ and appears to have been 
% modified and separated from the rest of the datatool dvt toolbox without 
% comment.
% VERSION:
%	$Revision: 1.4 $
%	$Date: 2008/01/19 19:28:45 $


nb = size(params,1);  %  number of boxplots
hw = 0.25;   %  halfwidth of boxes

%  if names are not given, make some
if nargin<3
   for ii = 1:nb
      names{ii} = ['Series' int2str(ii)];
   end
end

%  plot medians
plot(params(:,3),1:nb,'.','MarkerSize',18)
text(params(:,3),nb+0.3,num2str(params(:,3)),'HorizontalAlignment','center')
%  uses names for labels
set(gca,'YTick',1:nb)
set(gca,'YLim',[0 nb+1])
set(gca,'YTickLabel',[])
set(gca,'YDir','reverse')
ylabel(names)

hold on
%  plot quartiles as box
for ii = 1:nb
   temp1 = params(ii,2);
   temp2 = params(ii,4);
   xx = [temp1 temp1 temp2 temp2 temp1];
   yy = [ii-hw ii+hw ii+hw ii-hw ii-hw];
   plot(xx,yy,'-')
   text(temp1,ii-0.3,num2str(temp1),'HorizontalAlignment','right')
   text(temp2,ii-0.3,num2str(temp2))
end
%  plot adjacent values
for ii = 1:nb
   plot([params(ii,1) params(ii,2)],[ii ii],'--')
   plot([params(ii,4) params(ii,5)],[ii ii],'--')
   plot([params(ii,1) params(ii,1)],[ii-hw ii+hw],'--')
   plot([params(ii,5) params(ii,5)],[ii-hw ii+hw],'--')
   text(params(:,1),ii+0.3,num2str(params(:,1)),'HorizontalAlignment','right')
   text(params(:,5),ii+0.3,num2str(params(:,5)))
end
%  plot outside values
if exist('outsideValues')
    plot(outsideValues,repmat(ii,1,length(outsideValues)),'r+')
end
hold off

%  make some extra space
%axlim = axis;
%axlim(1) = axlim(1)-1;
%axlim(2) = axlim(2)+1;
%axis(axlim)



