美文网首页python学习笔记
学习笔记----python绘图hist

学习笔记----python绘图hist

作者: 三叠纪的小黑猫 | 来源:发表于2020-06-20 19:05 被阅读0次

    # python 绘制直方图


    import numpy as np

    import matplotlib.pyplot as plt

    np.random.seed(0)

    mu = 200

    sigma = 25

    x = np.random.normal(mu, sigma, size=100)

    print(x)

    fig, (ax0, ax1) = plt.subplots(ncols=2, figsize=(8, 4))

    ax0.hist(x, 20, normed=1, histtype='stepfilled', facecolor='g', alpha=0.75)

    ax0.set_title('stepfilled')

    # Create a histogram by providing the bin edges (unequally spaced).

    bins = [100, 150, 180, 195, 205, 220, 250, 300]

    ax1.hist(x, bins, normed=1, histtype='bar', rwidth=0.8)

    ax1.set_title('unequal bins')

    fig.tight_layout()

    plt.show()


    相关文章

      网友评论

        本文标题:学习笔记----python绘图hist

        本文链接:https://www.haomeiwen.com/subject/bqugxktx.html