In [1]:
%load_ext watermark
%watermark -a 'Hideki Tanaka' -u -d -v -p matplotlib,numpy,scipy
In [2]:
%matplotlib inline
In [3]:
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import numpy as np
from scipy.stats import norm
In [4]:
plt.style.use('ggplot')
plt.rc('xtick.major', size=0)
plt.rc('ytick.major', size=0)
In [5]:
np.random.seed(0)
In [6]:
x = np.random.randn(10000)
mu, sigma = norm.fit(x)
In [7]:
fig, ax = plt.subplots()
n, bins, patches = ax.hist(x, bins=50, normed=1, color="#3F5D7D")
y = mlab.normpdf(bins, mu, sigma)
l = plt.plot(bins, y, 'r--')
ax.set_title(r'$\mu=%.2f,\ \sigma=%.2f$' % (mu, sigma), fontsize=14)
ax.set_xlabel(r'$x$')
ax.set_ylabel(r'$\mathrm{Probability}$')
plt.show()
In [8]:
fig.savefig('../images/mpl_histogram.png', dpi=80)