plotting between two limits on a gaussian
This commit is contained in:
10
normdist.py
10
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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user