I have a large dataset and I'm trying to plot its scatterplot as well as an overlayed set of binned "summary" data points (in a different color of course). My intended effect is similar to this one
So far, I know how to sort my data's x-y matrix by the x-variable. How can I make it so that I cut this huge matrix into bins of equal width in the x-direction, and then find the average for all the y values within each bin? I feel like this task will be trivial once I can automatically slice my dataset into bins of arbitrary width in the x-direction.