I have made a chart using matplotlib in Python. I am trying to figure out how to make my Y Axis label more vague as you are zoomed out and more detailed when it is zoomed in. For example, if I am zoomed out all the way, I would like the label to show year and month as in 07/20 and 08/20. When you zoom in more it would show the days as well. 07/01/2020. When you get really zoomed in, you would be able to see date and time. Here is what my data looks like
i,datetime,count
0,2020-07-04 17:15:00,1
1,2020-07-04 17:30:00,1
2,2020-07-04 17:35:00,2
3,2020-07-04 17:45:00,2
4,2020-07-04 18:10:00,1
Here is what my chart looks like. What the chart looks like
Here is my code that is generating the chart.
plt.gca().xaxis.set_major_formatter(mdates.DateFormatter('%m/%d/%Y %H:%M'))
plt.gca().xaxis.set_major_locator(mdates.DayLocator())
plt.grid(True)
plt.plot(df['date_end'], df['count'], color='black');
plt.show()
Can someone point me toward the right direction?