I have the following code where I produced a 2d histogram with matplotlib of a function f of two variables, namely x and y. x goes from 0 to 7 and y from 0 to np.pi/2. Below you can find related code. I would like to project onto the x-axis so that I have the function f only as function of x: f(x). How can I do that? I would like to plot it as a 1d histogram and possibly save the values in a list.
from matplotlib import cm
plt.figure(figsize=(20,16))
h = plt.hist2d(x, y, bins=[110,110],cmin=0.000001,cmap='jet')
plt.colorbar(h[3])
plt.title("SW Distribution for Pion Zero",fontsize=22)
plt.xlabel("Momentum (GeV/c)",fontsize=22)
plt.ylabel("Angle (rad)",fontsize=22)
plt.xticks(fontsize=20)
plt.yticks(fontsize=20)
plt.show()