Python histogram outline

我怕爱的太早我们不能终老 提交于 2019-12-20 08:46:44

问题


I have plotted a histogram in Jupyter (Python 2) and was expecting to see the outlines of my bars but this is not the case.

I'm using the following code:

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()

回答1:


It looks like either your linewidth was set to zero or your edgecolor was set to 'none'. Matplotlib changed the defaults for these in 2.0. Try using:

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



来源:https://stackoverflow.com/questions/42741687/python-histogram-outline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!