Distribute month bars evenly in Matplotlib

Viewed 42

I am plotting monthly data in a bar chart using Matplotlib. This is very easy, as Matplotlib understands dates, and will place the bar at just the right place on the timeline, e.g. like this:

values = [0.3, 0.1, 0.4]
dates = [datetime(1955, 1, 1), datetime(1955, 2, 1), datetime(1955, 3, 1)]
pyplot.bar(dates, values)

The issue with months, however, is that because months are different lengths, there will be some spacing artifacts that just looks weird (even though they are technically correct) when plotting large time series:

See how February looks weird here

How can I tell Matplotlib to distribute the 12 months evenly across each year? (If it's possible it would be nice to keep dates in the x axis input, as it allows me to use other features, like matplotlib.dates.MonthLocator/YearLocator etc)

0 Answers
Related