I want to plot time series data with dates on the X axis. The data was collected on different days with unequal distance between the dates. This is not the same thing as asked here matplotlib string to dates because they were asking how to convert date strings to plot. I'm not asking how to convert date strings to plot. My question is specifically about how to plot date data with unequal distance between dates.
Here's an example:
import matplotlib
import matplotlib.pyplot as plt
y = [1, 2, 3, 4, 5]
dates = ['2020-DEC-01', '2020-DEC-02', '2020-DEC-09', '2020-DEC-19', '2021-DEC-01']
days = [0, 1, 8, 18, 365]
%matplotlib notebook
fig,ax = plt.subplots(figsize=(10, 10))
ax.plot_date(dates, y, 'k', xdate=True)
ax.plot(days, y, 'k')`
When I plot the dates, the data points are equally spaced which is not what I want:
What it should look like is something like this (except with dates on the x-axis labels):
How do I plot data with uneven amount of time between data points so that the x-axis accurately portrays the time duration scaled appropriately?