lundi 5 juillet 2021

How can i paint random values under a curve python?

I want to paint the random numbers that are shown under the curve of a color, and those that are above another color, I tried putting my values in arrays and putting an if, I have been trying but I have not obtained result, this is my code: import numpy as np import matplotlib.pyplot as plt

def func(x):
    return (np.exp(-x))*x**2
f = np.linspace(0, 10, 1000)
y = func(f)
yw=np.array(y)
plt.plot(f, y)
plt.axhline(y=0.6, xmin=0, xmax=10)
h=np.random.randn(1000)
h2=np.array(h)
#if(h2>yw):
 #   plt.plot(f,h,'mo')
#else:        
plt.plot(f, y)
plt.plot(f,h,'co')
plt.xlim(0,10)
plt.ylim(0,0.6012)



Aucun commentaire:

Enregistrer un commentaire