添加边缘颜色勾勒出的直方图

问题描述 投票:0回答:1

我在 Jupyter (Python 2) 中绘制了一个直方图,并希望看到我的条形图的轮廓,但事实并非如此。

我正在使用以下代码:

import matplotlib.pyplot as plt
from numpy.random import normal
gaussian_numbers = normal(size=1000)
plt.hist(gaussian_numbers)
plt.title("Gaussian Histogram")
plt.xlabel("Value")
plt.ylabel("Frequency")
plt.show()
python matplotlib histogram
1个回答
172
投票

看起来您的

linewidth
设置为零,或者您的
edgecolor
设置为
'none'
。 Matplotlib 在 2.0 中更改了这些的默认值。尝试使用:

plt.hist(gaussian_numbers, edgecolor='black', linewidth=1.2)

© www.soinside.com 2019 - 2024. All rights reserved.