Is it possible to switch X axis in Python matplotlib.pyplot.hist from bin edges to exact values? In other words this is what I get:
dataset = [0,1,1,1,2,2,3,3,4]
plt.hist(dataset, 5, rwidth=0.9)
Is it possible to switch X axis in Python matplotlib.pyplot.hist from bin edges to exact values? In other words this is what I get:
dataset = [0,1,1,1,2,2,3,3,4]
plt.hist(dataset, 5, rwidth=0.9)
You can first compute the frequencies and then use a bar plot
from collections import Counter
import matplotlib.pyplot as plt
dataset = [0,1,1,1,2,2,3,3,4]
freqs = Counter(dataset)
plt.bar(freqs.keys(), freqs.values(), width=0.9)
plt.show()