import numpy as np import matplotlib.pyplot as plt prices = np.full(100, fill_value=np.nan) prices[[0, 25, 60, -1]] = [80.0, 30.0, 75.0, 50.0] # Linearly interpolate the missing values and add some noise. x = np.arange(len(prices)) is_valid = ~np.isnan(prices) prices = np.interp(x=x, xp=x[is_valid], fp=prices[is_valid]) prices += np.random.randn(len(prices)) * 2 mn = np.argmin(prices) mx = mn + np.argmax(prices[mn:]) kwargs = {"markersize": 12, "linestyle": ""} fig, ax = plt.subplots() ax.plot(prices) ax.set_title("Price History") ax.set_xlabel("Time") ax.set_ylabel("Price") ax.plot(mn, prices[mn], color="green", **kwargs) ax.plot(mx, prices[mx], color="red", **kwargs) plt.show()