When I run df.index
, it outputs the format as YYYY-MM-DD, which is how I would like it viewed on the figure. Instead, at each major tick the values are, for example, 1.48 1e18, 1.50 1e18, etc. Is there a simple way to convert to the aforementioned format?
from datetime import datetime as dt
import matplotlib.pyplot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
start = dt(2016, 6, 1)
end = dt.now()
df = web.get_data_yahoo('AAPL', start, end, interval = 'd')
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.plot(df.index, df['Adj Close'], label='ADJ CLOSE')
ax.set_xlabel('Date')
ax.set_ylabel('Price')
ax.legend()
plt.show()
Using Python 3.6.2 and pandas 0.21.0