我有一个超过 10 年的时间序列,并且想将 xtick 标签缩写为 2 位数的年份。我怎样才能做到这一点 ?
import matplotlib.pyplot as plt
import datetime as dt
import pandas as pd
import pandas.io.data as web
stocklist = ['MSFT']
# read historical prices for last 11 years
def get_px(stock, start):
return web.get_data_yahoo(stock, start)['Adj Close']
today = dt.date.today()
start = str(dt.date(today.year-11, today.month, today.day))
px = pd.DataFrame({n: get_px(n, start) for n in stocklist})
plt.plot(px.index, px[stocklist[0]])
plt.show()