In [1]:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
In [2]:
%matplotlib inline
In [3]:
def f(x):
    # standard Normal density function
    return np.exp(-x*x) / np.sqrt(2 * np.pi)
vf = np.vectorize(f)
In [4]:
x = np.linspace(-3,3,301)
y = vf(x)
a = 1.5
off = np.where(x==-a)[0][0]
print(off)
z = np.zeros(301)

fig, ax = plt.subplots(1,1)
ax.spines['left'].set_position('center')

# Eliminate upper and right axes
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')

# Show ticks in the left and lower axes only
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
ax.tick_params(axis='x',labelbottom='off')
ax.tick_params(axis='y',labelleft='off')

ax.plot(x,y, 'k');
ax.axvline(a,linestyle='--',color='#999999')
ax.axvline(-a,linestyle='--',color='#999999')
ax.fill_between(x[:off],y[:off],z[:off],color='#ddddff')
ax.fill_between(x[off:-off],y[off:-off],z[off:-off],color='#ffffdd')
ax.fill_between(x[-off:],y[-off:],z[-off:],color='#ddddff');
75