I have two lists of floats. I can see that the floats in the two lists range from 0.003 to 0.99.
The lists are too long to paste here, but they would look like this:
list1 = [0.03, 0.4, 0.4, 0.5, 0.5, 0.6, 0.7, 0.993]
list2 = [0.4, 0.3, 0.2, 0.7, 0.002, 0.4, 0.01, 0.3]
and I can see that there is definitely values in the list ranging from <0.1 to >0.9.
When I run this code to plot both of these lists as histograms on one plot:
import matplotlib.pyplot as plt
plt.hist(list1, alpha=0.5)
plt.hist(list2,alpha=0.5)
plt.savefig('test_histogram.png')
The output looks like this:
But there's no error. There's definitely plenty of values <0.8 so it's not just that the values are so small that they're not seen. Would someone have an explanation of what's happening?
CodePudding user response:
Just pass 'histtype' as bar
plt.hist(list1, alpha=0.5, density=True, histtype='bar')
plt.hist(list2,alpha=0.5, density=True, histtype='bar')
plt.show()`