diff --git a/normdist.py b/normdist.py index 6483e1f..ea3456d 100644 --- a/normdist.py +++ b/normdist.py @@ -6,11 +6,19 @@ from scipy.stats import norm mean = 1 stddev = 5 +lowerbound = -1 +upperbound = 1 x = np.linspace(-10, 10 , 1000) -plt.plot(x, norm.pdf(x, mean, stddev), 'b-', label='Normal Distribution') +y = norm.pdf(x, mean, stddev) +plt.plot(x, y, 'b-', label='Normal Distribution') +coloredregion = (x >= lowerbound) & ( x <= upperbound ) #select x values +plt.vlines([lowerbound, upperbound], 0, plt.ylim()[1])#ylim returns [bot, top] + +plt.fill_between(x, 0, y, where=coloredregion, color="grey", alpha=0.5, label="Design Range") plt.xlabel('X') plt.ylabel('Probability Density') plt.legend() plt.grid(True) plt.show() +