1import pandas as pd
2import numpy as np
3import matplotlib.pyplot as plt
4import matplotlib.dates as mdates
5
6dates = pd.date_range('20070101',periods=1000)
7df = pd.DataFrame(np.random.randn(1000), index = dates, columns =list ('A'))
8
9fig,ax = plt.subplots()
10df.plot(x_compat=True,ax=ax)
11
12ax.xaxis.set_tick_params(reset=True)
13ax.xaxis.set_major_locator(mdates.YearLocator(1))
14ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y'))
15
16plt.show()