'Peaks Find on Hist and DF Python

We are trying to wrote a code that help us to find peaks in a histo like this:

enter image description here

In the previus image we can see 13 peaks that we want to find and put in a pandas DF. In order to do this we wrote the following:

fig1 = px.histogram(df[(df['CH']==44)], x='HG', title='HG Multiphoton Spectrum')
#fig1 = px.histogram(df, x='HG', title='HG Multiphoton Spectrum')
fig1.update_traces(xbins=dict(start=0, end=8196, size=2))
fig1.show()


data = df[(df['CH']==44)]

data_raw = data[['HG']].T

data_final = np.array(data_raw).squeeze()

print(data_final)

x = data_final

peaks, _ = find_peaks(x, height=50, width=10)

counts, bins = np.histogram(data_final)
plt.hist(bins[:-1], bins, weights=counts)

plt.plot(peaks, x[peaks], "x")

plt.show()

But the code gives this output:

enter image description here

I don't understand why i don't see the previous histo with the peaks that the code find. It is possible to use pyplot for implement the hist like the previous?

Here the full code and data file:

Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source