import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
直方图
x = np.random.normal(0,20,100)
bins = np.arange(-100,100,5)
plt.hist(x, bins=bins)
plt.xlim([min(x)-5,max(x)+5])
(-61.3905975546451, 50.14653064924281)
x1 = np.random.normal(0,20,100)
x2 = np.random.normal(10,30,100)
bins = np.arange(-100,100,5)
plt.hist(x1, bins=bins, alpha=0.3)
plt.hist(x2, bins=bins, alpha=0.3)
(array([ 0., 0., 0., 0., 0., 1., 0., 2., 2., 2., 1., 3., 2.,
1., 3., 4., 3., 2., 5., 5., 7., 11., 7., 4., 3., 5.,
4., 5., 3., 4., 3., 3., 2., 0., 2., 0., 0., 1., 0.]),
array([-100, -95, -90, -85, -80, -75, -70, -65, -60, -55, -50,
-45, -40, -35, -30, -25, -20, -15, -10, -5, 0, 5,
10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60,
65, 70, 75, 80, 85, 90, 95]),
<a list of 39 Patch objects>)