-2

I am currently trying to render a histogram using Python's matplotlib. I'm having difficulty drawing vertical lines between each of the bins.

Here is my current code

plt.figure(figsize=[10, 5])

array = np.random.normal(loc=0, scale=1, size=100)
plt.hist(array, bins=25, color='#0504AA', alpha=0.5)

plt.grid(axis='x', alpha=0.5)
plt.grid(axis='y', alpha=0.5)

plt.xlabel('Value',     fontsize=12.5)
plt.ylabel('Frequency', fontsize=12.5)

plt.xticks(fontsize=12.5)
plt.yticks(fontsize=12.5)

plt.title('Histogram Distribution', fontsize=12.5)
plt.show()

Here is the current output

enter image description here

Here is the desired output

enter image description here

Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
AlanSTACK
  • 5,525
  • 3
  • 40
  • 99

1 Answers1

1

Try this:

plt.hist(array, bins=25, color='#0504AA', alpha=0.5,edgecolor ="black", linewidth=2)

https://i.stack.imgur.com/6qGpu.png

Atheer
  • 85
  • 10