What happens is that matplotlib does not actually use datetime objects to build.
Dates are first converted to internal floating point format. The conversion is not configured to handle timedeltas (which may be oversight).
Basically you can do exactly what you wanted, you just need to explicitly convert the dates to the matplotlib internal format, and then call ax.xaxis_date()
.
As a quick example (most of this is generating data to build ...):
import datetime as dt import matplotlib.pyplot as plt import matplotlib.dates as mdates def drange(start, end, interval=dt.timedelta(days=1)): output = [] while start <= end: output.append(start) start += interval return output
![enter image description here](https://fooobar.com/undefined)
source share