Here is an example as far as I can understand what your goal is
import datetime as dt import matplotlib.pyplot as plt import matplotlib.dates as mdates import random x = mdates.drange(dt.datetime(2021, 3, 1, 0, 0, 0), dt.datetime(2021, 3, 3, 0, 0, 0), dt.timedelta(hours=1)) y = [random.randint(0,100) for _ in range(len(x))] time = mdates.drange(dt.datetime(2021, 3, 1, 0, 0, 0), dt.datetime(2021, 3, 3, 1, 0, 0), dt.timedelta(hours=6)) fig, ax = plt.subplots(figsize=(8, 6)) plt.xticks(time) ax.xaxis.set_major_formatter(mdates.DateFormatter("%m-%d %H:%M")) # ax.xaxis.set_minor_formatter(mdates.DateFormatter("%m-%d %H:%M")) ax.plot(x, y, 'bo-') ax.set(title='Active Calls', ylabel='Calls', xlabel='Time') ax.grid() ax.xaxis_date() # Default date formatter fig.autofmt_xdate() plt.show()
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs