from scipy import stats
import matplotlib.pyplot as plt
x = np.linspace(-5,5,100)
#normal distribution, mean =0, deviation = 1
y = stats.norm.pdf(x,0,1)
plt.plot(x,y)
plt.fill_between(x, y, color='yellow')
fill between normal distribution and x axis
y2 = x**2plt.plot(x,y2)
plt.fill_between(x, y, y2, color='yellow')
plt.ylim(0, 0.4)
fill between normal distribution and parabola
plt.fill_between(x, y, y2, where=y>y2, color='yellow')
filter out outside region
reference:
https://www.quantopian.com/lectures/confidence-intervals
https://www.science-emergence.com/Articles/How-to-fill-an-area-in-matplotlib-/
https://matplotlib.org/3.1.1/gallery/lines_bars_and_markers/fill_between_demo.html
No comments:
Post a Comment