1

I'm a beginner to matplotlib's pyplot and was wondering how to get black lines between the bars of the histogram. I did some googling and others were seeming to get this behavior out of the box with the same commands as I was using.

enter image description here

1 Answers1

4

With matplotlib version 2, transparent edges in histograms became the default(Reference), to modify that just add the edgecolor = 'black' parameter to your plt.hist:

plt.hist(data, 20, alpha=.5, edgecolor = 'black')

Demo with random data:

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

Vinícius Figueiredo
  • 6,300
  • 3
  • 25
  • 44