频次直方图的简单入门
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('seaborn-white')
data = np.random.randn(1000)
#最基本的频次直方图命令
plt.hist(data)
#调节具体参数
#bins调节横坐标分区个数,alpha参数用来设置透明度
plt.hist(data, bins=30, normed=True, alpha=0.5, histtype='stepfilled',
color='steelblue', edgecolor='none'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
#对不同的分布特征样本进行对比,将histtype="stepfilled"与透明性设置参数alpha搭配使用
x1 = np.random.normal(0,0.8,1000)
x2 = np.random.normal(-2,1,1000)
x3 = np.random.normal(3,2,1000)
kwargs = dict(histtype="stepfilled"