import matplotlib.pyplot as plt
import numpy as np
#plt.rc('text', usetex=True)

xb = 1.5
xl = -4.
xh = 6.
sig = 1.5

def gauss(x,xb,sig):
    a = 1./np.sqrt(2*np.pi*sig*sig)
    b = np.exp(-((x-xb)**2)/(2*sig**2))
    return a*b

fig, ax = plt.subplots()
x = np.linspace(xl,xh,100)
ax.plot(x,gauss(x,xb,sig),c='k',lw=2)
ax.plot([xb,xb],[0,1./np.sqrt(2*np.pi*sig*sig)],ls='-.',color='k')
ax.set_xlabel('x',fontsize=16)
ax.set_ylabel('f(x)',fontsize=16)
ax.tick_params(labelsize=15)
ax.set_xlim([-4,6])
ax.set_ylim([0,0.3])
ax.set_xticks(np.arange(-4,7))
lab_top = r'$\bar{x} = 1.5$'
ax.text(xb,0.27,lab_top,fontsize=16)
ty = np.exp(-0.5)/np.sqrt(2*np.pi*sig*sig)
print 1.5,ty,sig,0
ax.arrow(1.5,ty,sig,0,head_width=0.02,head_length=0.5,length_includes_head= 'true',color='k')
sig_text = r'$\sigma$'
ax.text(1.8,ty*1.1,sig_text,fontsize=16)
plt.savefig('gaussian.eps',dpi=100,bbox_inches='tight')
plt.show()
