Matplotlib dates YearLocator with odd intervals
问题 Right now I have a working bit of code that formats to my specification when my time series begin at the start of a decade (i.e. 1990, 2000, 2010,etc.), but I don't know how to adapt my code to have the correct formatting when my time series begins at a year that isn't even (i.e. 1993). import pandas as pd import matplotlib.pyplot as plt from matplotlib import dates def format_xaxis(fig): years = dates.YearLocator(10,month=1,day=1) years1=dates.YearLocator(2,month=1,day=1) dfmt = dates