Apr-04-2022, 07:10 PM
(Apr-04-2022, 04:33 PM)deanhystad Wrote: If you look at the documentation for matplotlib.ticker
https://matplotlib.org/stable/api/ticker_api.html
You see this
Quote:There are a number of locators specialized for date locations - see the dates module.Follow the link:
Here's what I ended up with:
import pandas as pd import matplotlib.pyplot as plt sample_data = [3, 6, 2, 12, 15] e = pd.date_range('2010-01-01', '2011-12-31',5) #these will be x-coordinates for data f = pd.date_range('2009-06-30', '2014-12-31',10) #these will be x-axis labels f = f.strftime('%Y-%m-%d') #reformatted axis labels fig, ax = plt.subplots(1) ax.plot(e,sample_data) ax.set_xticks(f, f, rotation=90) plt.show()That seems to work.
Thanks all!