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.
Asked
Active
Viewed 2,071 times
1 Answers
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