Created
April 28, 2022 14:22
-
-
Save databyjp/6fadec7ea7a2c216535ce00ad451d1c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig = px.scatter(shot_blot_df, | |
title=f'{latest_day_str} - Playoff game shot profiles', | |
x="filt_avg", y="segment", size="pts_pct_x", | |
color="shot_ev", color_continuous_scale=px.colors.sequential.Blues, | |
facet_row="group", facet_col="shot_type", | |
template="plotly_white", width=1200, height=750, | |
range_color=[0.7, 1.7], | |
labels={'filt_avg': 'Distance from the rim', 'segment': 'Sample size', | |
'pts_pct_x': 'Proportion of points', 'shot_ev': 'Expected<BR>points<BR>per shot'} | |
) | |
fig.update_traces(marker=dict(line=dict(color="#b0b0b0", width=0.5))) | |
import re | |
for k in fig.layout: | |
if re.search('xaxis+', k): | |
fig.layout[k].update(matches=None) | |
print(k) | |
if k[-1] == 's' or int(k[-1]) % 2 != 0: | |
fig.layout[k].update(domain=[0.0, 0.704]) | |
else: | |
fig.layout[k].update(domain=[0.724, 0.98]) | |
for i in fig.layout.annotations: | |
if i['text'] == 'shot_type=3pt': | |
i['x'] = 0.852 | |
# Increase the overall top margin, and move the title up slightly | |
fig.update_layout( | |
margin=dict(t=140), | |
title={'y':0.95, 'yanchor': 'top'} | |
) | |
# Add the subhead | |
fig.add_annotation(text="Marker size: Percentage of team points from that distance (1ft radius)<BR>Marker colour: Efficiency (points per shot)", | |
xref="paper", yref="paper", align="left", | |
font=dict(color="slategrey"), | |
x=-0.065, y=1.15, showarrow=False) | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment