Skip to content

Instantly share code, notes, and snippets.

@jes-moore
Created December 22, 2018 19:27
Show Gist options
  • Save jes-moore/722f524c45732ec023738c307eba006c to your computer and use it in GitHub Desktop.
Save jes-moore/722f524c45732ec023738c307eba006c to your computer and use it in GitHub Desktop.
## Scoring Ratio Chart
shotTimeData = go.Scatter(
x=shot_df_agg.loc[0:20, 'shotTimeDiff'],
y=shot_df_agg.loc[0:20, 'goalRatio'],
mode='markers+lines',
text=shot_df_agg.loc[0:20, 'goalRatioText'],
hoverinfo='text')
data = [shotTimeData]
## Layout
layout = go.Layout(
title='Scoring Ratio on Rebounds (2012 - 2018)',
height=400,
width=800,
yaxis=dict(range=[0, 0.5], title='Scoring Ratio (Goals # / Shots #)'),
xaxis=dict(range=[0, 21.5], title='Seconds Since Last Shot'))
#Fig and Plot
fig = go.Figure(data=data, layout=layout)
iplot(fig)
## Number of Goals/Shots Chart
numGoalsData = go.Scatter(
x=shot_df_agg.loc[0:20, 'shotTimeDiff'],
y=shot_df_agg.loc[0:20, 'numGoals'],
mode='markers+lines',
name='Goal Count')
numShotsData = go.Scatter(
x=shot_df_agg.loc[0:20, 'shotTimeDiff'],
y=shot_df_agg.loc[0:20, 'numShots'],
mode='markers+lines',
name='Shot Count')
data = [numGoalsData, numShotsData]
## Layout
layout = go.Layout(
title='Goal and Shot Count for Rebounds (2012 - 2018)',
height=400,
width=800,
xaxis=dict(range=[0, 21.5], title='Seconds Since Last Shot'),
yaxis=dict(title='Number of Shots and Goals'))
#Fig and Plot
fig = go.Figure(data=data, layout=layout)
iplot(fig)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment