Hi I'm looking for a program to find the maxima of multiple bands in a plot, yet I've found away to only localize the biggest maximum, I want to determine the coordinates of the second maximum.
here is my script
`import numpy as np
import matplotlib.pyplot as plt
a2=np.loadtxt('O-25.txt')
x2=a2[:,0]
y2=a2[:,1]
y2Max = max(y2)
print(y2Max)
zz = y2/y2Max
#plt.plot(x2,zz,linewidth=2,label="B3lyp")
fig, ax = plt.subplots()
ax.plot(x2,zz,linewidth=2,label="")
def annot_max(x2,zz, ax=None):
xmax = x2[np.argmax(zz)]
ymax = zz.max()
text= "x={:.3f}, y={:.3f}".format(xmax, ymax)
if not ax:
ax=plt.gca()
bbox_props = dict(boxstyle="square,pad=0.3", fc="w", ec="k", lw=0.72)
arrowprops=dict(arrowstyle="->",connectionstyle="angle,angleA=0,angleB=60")
kw = dict(xycoords='data',textcoords="axes fraction",
arrowprops=arrowprops, bbox=bbox_props, ha="right", va="top")
ax.annotate(text, xy=(xmax, ymax), xytext=(0.94,0.96), **kw)
annot_max(x2,zz)
plt.xlabel('wavelength(nm)' , fontname='arial', fontsize=14)
plt.ylabel('energy (cm-1)' , fontname='arial', fontsize=14)
plt.title("O-")
plt.legend()`