【问题标题】:Matplotlib PyPlot Lines in Histogram [duplicate]直方图中的 Matplotlib PyPlot 线 [重复]
【发布时间】:2017-12-12 22:01:25
【问题描述】:

我是 matplotlib 的 pyplot 的初学者,想知道如何在直方图的条之间获得黑线。我做了一些谷歌搜索和others were seeming to get this behavior,使用与我使用的相同的命令。

【问题讨论】:

    标签: python matplotlib


    【解决方案1】:

    matplotlib 版本 2 中,直方图中的透明边缘成为默认设置(Reference),要修改它只需将edgecolor = 'black' 参数添加到您的plt.hist

    plt.hist(data, 20, alpha=.5, edgecolor = 'black')
    

    带有随机数据的演示:

    import numpy as np
    import matplotlib.pyplot as plt
    
    mu, sigma = 100, 15
    x = mu + sigma*np.random.randn(10000)
    plt.hist(x, 20, alpha=0.5, edgecolor = 'black')
    plt.show()
    

    【讨论】:

      猜你喜欢
      • 2021-01-25
      • 1970-01-01
      • 2013-12-24
      • 2019-08-30
      • 2021-03-25
      • 2015-07-26
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多