I have a list of points. I want to put an equal number of points in an equal number of bins in a histogram. Ideally it would not be hard coded so in the future I could have uneven amounts of points in any number of bins.
Then I want to find the mean for each bin and plot these values on the same graph.
I should end up with either a scatter plot or histogram of the total data with the specific means plotted on top of that.
I found some code to put equal amounts of data into bins. But I am struggling moving forward.
data = [list of 1103 points]
b = number of bins
def histedges(data, binss):
n = len(x)
return np.interp(np.linspace(0, n, binss + 1),
np.arange(n),np.sort(data))
n, bins, patches = plt.hist(dis, histedges(data, b))