function [xx, yy, err_yy] =  func_calc_slope_barplot(slope, sdata)

    ngroups = 10;
    x = slope; y = sdata;

    [x_sort, ind] = sort(x(:)); y_sort = y(ind);

    x_edge = quantile(x_sort,ngroups-1);
    [counts, Id] = histc(x_sort,[-inf; x_edge(:); inf]);
    
    for igrp = 1:ngroups
        
        x2d_g = x_sort(Id==igrp);y2d_g = y_sort(Id==igrp);
        xx(igrp) = nanmean(x2d_g);
        yy(igrp) = nanmean(y2d_g);
        err_yy(igrp) = nanstd(y2d_g);
    end

end