<分区>
我是 matplotlib 的 pyplot 的初学者,想知道如何在直方图的条形之间获得黑线。我做了一些谷歌搜索和others were seeming to get this behavior开箱即用,命令与我使用的相同。
标签 python matplotlib
<分区>
我是 matplotlib 的 pyplot 的初学者,想知道如何在直方图的条形之间获得黑线。我做了一些谷歌搜索和others were seeming to get this behavior开箱即用,命令与我使用的相同。
最佳答案
使用 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()
关于python - 直方图中的 Matplotlib PyPlot 线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44990525/