【发布时间】:2017-12-12 22:01:25
【问题描述】:
我是 matplotlib 的 pyplot 的初学者,想知道如何在直方图的条之间获得黑线。我做了一些谷歌搜索和others were seeming to get this behavior,使用与我使用的相同的命令。
【问题讨论】:
标签: python matplotlib
我是 matplotlib 的 pyplot 的初学者,想知道如何在直方图的条之间获得黑线。我做了一些谷歌搜索和others were seeming to get this behavior,使用与我使用的相同的命令。
【问题讨论】:
标签: python matplotlib
在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()
【讨论】: