In [6]:
import pandas as pd
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
#from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
plotly.tools.set_credentials_file(username='chrisstrods', \
api_key='p08RarvxlyCxeqUU0kPS')
#init_notebook_mode(connected=True)
elomatches = pd.read_csv("elo_out.csv")
#Select 2018 matches and remove old teams
elo2018 = elomatches.loc[elomatches["season"] == 2018]
elo2018 = elo2018.dropna(axis='columns')
#Select Port's origin
PAhis = elomatches.loc[elomatches["season"] >= 1997]
PAhis = PAhis.dropna(axis='columns')
In [7]:
traces = []
teams = ["Adelaide","Brisbane Lions","Carlton","Collingwood","Essendon","Fremantle","Geelong","Gold Coast",
"Greater Western Sydney","Hawthorn","Melbourne","North Melbourne","Port Adelaide","Richmond","St Kilda","Sydney",
"West Coast","Footscray"]
teamlabels = ["Adelaide","Brisbane Lions","Carlton","Collingwood","Essendon","Fremantle","Geelong","Gold Coast",
"Greater Western Sydney","Hawthorn","Melbourne","North Melbourne","Port Adelaide","Richmond","St Kilda","Sydney",
"West Coast","Western Bulldogs"]
teamcolours = ['rgb(242,0,23)','rgb(155, 0, 51)','rgb(2,26,49)','rgb(0,0,0)','rgb(255,17,0)','rgb(29,17,96)',
'rgb(5,23,63)','rgb(155,25,33)','rgb(247,143,30)','rgb(54,21,0)','rgb(2,26,49)','rgb(14,43,141)',
'rgb(0, 142, 143)','rgb(255,214,0)','rgb(252,25,33)','rgb(242,0,23)','rgb(5,23,63)','rgb(13,54,156)']
rounds = elo2018["round"]
for i in range(0,18):
traces.append(go.Scatter(
x = elo2018["round"],
y = elo2018[teams[i]],
mode = 'lines',
name = teamlabels[i],
line = dict(
color = (teamcolours[i]),
width = 4)))
layout = go.Layout(
autosize=False,
width=800,
height=600,
paper_bgcolor='#ffffff',
legend=dict(x=-0.5, y=0))
data = traces
fig = go.Figure(data=data,layout=layout)
py.iplot(fig,filename='ELO2018-LINES')
Out[7]:
In [8]:
candlestick_open = []
candlestick_close = []
candlestick_max = []
candlestick_min = []
for i in range(0,18):
candlestick_open.append(elo2018[teams[i]].iloc[0])
candlestick_close.append(elo2018[teams[i]].iloc[-1])
candlestick_max.append(max(elo2018[teams[i]]))
candlestick_min.append(min(elo2018[teams[i]]))
trace = go.Candlestick(x=teamlabels,
open=candlestick_open,
high=candlestick_max,
low=candlestick_min,
close=candlestick_close)
data = [trace]
py.iplot(data,filename='ELO2018-CANDLESTICK')
Out[8]:
In [ ]:
In [ ]: