python - 直方图中的 Matplotlib PyPlot 线

标签 python matplotlib

<分区>

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

enter image description here

最佳答案

使用 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/

相关文章:

python - 提取单词和分隔符之间的单词python

python - Django Python - Itertools 没有使产品与拍卖销售额保持一致

Python:两个FOR循环,第一个不继续

python - 添加箭头到股票图表

python - 如何在 Amazon S3 上存储 scrapy 图像?

python - VTK 与真正的 X 一起工作,与 Xvfb 一起崩溃

python - Matplotlib - 创建填充的二维等高线图

python - Matplotlib:如何使背景透明?

javascript - 如何在 python jupyter notebook 中绘图?

python - 如何将多个列绘制到单个seaborn箱线图中