I am studying financial time series, in the format of pandas series. To compare two series I do a scatterplot, and to visualise the time evolution in the scatterplot I can colour them. This is all fine.
My question relates to the legend showing the colours. I would like the legend to show the date/year that the colour corresponds to, rather than just an the index of the data entry, as now. But I haven't been able to do this, or to find a question like this on stackoverflow.
I know the time series knows the dates, and if you just plot a time series, the x-axis will show the dates.
My code is
from pandas_datareader import data as web
import matplotlib.pyplot as plt
import pandas as pd
#Download data
start = '2010-1-1'
end = '2016-10-1'
AAPL = web.DataReader('AAPL', 'yahoo', start=start, end=end)['Adj Close']
TSLA = web.DataReader('GOOG', 'yahoo', start=start, end=end)['Adj Close']
#Scatterplot
plt.scatter(AAPL, TSLA, alpha=.4, c=range(len(AAPL)))
plt.colorbar()
plt.xlabel("AAPL")
plt.ylabel("TSLA")
plt.grid()
plt.show()
This code produces this plot: Scatterplot with colours and legend
Thanks