function bin_and_scatterplot(xvar,yvar)
%takes as inputs two variables, to plot against each other, with binning along the x variable for computation of mean and SD, 
%and plotting of raw data, with a bit of random scatter for visibility

poss_states=0:max(xvar)
newxvar=xvar;
means=repmat(nan,1,length(poss_states));
stds=means;

for i=poss_states
    exes=find(xvar==i);
    whys=yvar(exes);
    means(i+1)=mean(whys);
    stds(i+1)=std(whys);
    
    rando=rand(1,length(exes))-0.5;
    xscat=xvar(exes)+rando;
    newxvar(exes)=xscat; 
end

hold on
plot(newxvar,yvar,'r.')
hold on
errorbar(poss_states,means,stds,'r')