%%function [line,xthresh,n,x]=d2chplot(data,binsize,sigma,str);
%%By Joakim Lindblad 2000-01-25
%%Added n,x JL 2000-06-20
function [line,xthresh,n,x]=d2chplot(data,binsize,sigma,str);

h=0;
if ~ishold
  h=1;
end;

[xthresh,n,x]=d2chist(data,x_interval(data,binsize),sigma);
line=plot(x,2*n*sigma.^2,str);
hold on;
nb=hist(data,x_interval(data,1));

line(length(line)+1)=plot([xthresh-1,xthresh-1],[0,max(nb)],'k');
ylim([min(n)*1.1,max(nb)*1.1]);

text(xthresh,max(nb),sprintf('  %.2f',xthresh));

if h
  hold off
end;

