Vote count:
0
My legend doesn't match the line colors. Any idea how I go about fixing this and what I am doing wrong? The code downloads the data from yahoo finance so you should be able to run it as is on your machine and see the data yourself. Thanks for your help!
import pandas.io.data as web
import pandas as pd
import matplotlib.pyplot as plt
import datetime
start = '5/1/2007'
end = '10/1/2007'
event = datetime.date(2007,6,27)
companies = ['AAPL','MSFT','BBRY']
all_data = {}
for ticker in companies:
all_data[ticker] = web.get_data_yahoo(ticker, start,end)
price = pd.DataFrame({tic:data['Adj Close']
for tic, data in all_data.iteritems()})
volume = pd.DataFrame({tic:data['Volume']
for tic, data in all_data.iteritems()})
rels = price/price.ix[event]
plt.figure(figsize=(15,5))
plt.axvline(x=event)
plt.plot(rels.index, rels, lw=4.0)
plt.legend(companies,loc='upper left')
plt.grid(True)
plt.show()
asked 21 secs ago
pyplot legend not matching lines
Aucun commentaire:
Enregistrer un commentaire