I want to find local minimas from an array or list. By the following code I can find local maximas.I know that there exists related questions, but still I just want to know, if there exists any logic by which I can use the same code for finding local minimas.
Code:
import matplotlib.pyplot as plt
from scipy.misc import electrocardiogram
from scipy.signal import find_peaks
x = electrocardiogram()[2000:4000]
peaks, _ = find_peaks(x, height=0)
plt.plot(x)
plt.plot(peaks, x[peaks], "x")
plt.plot(np.zeros_like(x), "--", color="gray")
plt.show()