DEV Community


Answer: Cannot get histogram to show separated bins with vertical lines

Nilotpal Choudhury
Supply Chain professional with an interest in the fast growing world of data analytics
ใƒป1 min read

Using your example:

import numpy as np
import matplotlib.pyplot as plt

x = np.random.rand((100)) 
bins = np.linspace(0, 2, 40)
plt.title('Relative Amplitude',fontsize=30)
plt.xlabel('Random Histogram')
plt.hist(x, bins, alpha=0.5, histtype='bar', ec='black')

plt.legend(loc='upper right',fontsize=30)
plt.xticks(fontsize = 20) 
plt.yticks(fontsize = 20) 

Which produces the following image:

enter image description here

The key difference is the use ofโ€ฆ

Discussion (0)