Matplotlib Histogram Alignment
histogram, matplotlib, python
Solution
This is clearly because the bin edges of your resulting histogram are not just even numbers 0,2,4....22.
To get the desired result, simply make use of the `bins=` argument and, i.e., :
plt.hist(YOUR_DATA,bins=arange(0,24,2)) #for bin edge 0,2,4...,22, as in your figure.
Problem
``` def vs_time(data): #MUBASHWER, histogram clf() hist(data.keys(), bins = 12, weights = data.values()) xticks(arange(0,24,2)) xlabel('Time') ylabel('Number of fatalities') title('Number of Fatalities vs Time') webshow('vs_time.png') ``` histogram: I want the hours in x-axis to be on the left edge of each bar. But they are neither at the centre, nor at any edge. Please help. The problem could be solved if the histogram could be shirted without altering the axis.