Python histogram outline

PythonMatplotlibHistogram

Python Problem Overview


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.

enter image description here

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

Python Solutions


Solution 1 - Python

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)

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrad ReedView Question on Stackoverflow
Solution 1 - PythonJamesView Answer on Stackoverflow