Shooting guards versus small forwards
The sports media agency will be producing a blog comparing the importance of shooting guards and small forwards in points production. They have asked you to produce a scatter plot displaying points and assists per game for each of the two positions, using different glyph colors, sizes, and transparency.
The nba dataset has been filtered for "SG" and "SF", and preloaded for you as two Bokeh source objects called shooting_guards and small_forwards. A HoverTool has also been created to display "player", "team", and "field_goal_perc".
Este exercício faz parte do curso
Interactive Data Visualization with Bokeh
Instruções do exercício
- Add circle glyphs for points per game versus average assists using
shooting_guards, settingsizeto 16 pixels,fill_colorto red, and assigning0.2to the relevent keyword argument for glyph transparency. - Add circle glyphs to represent points versus average assists for small forwards, filled in green, 6 pixels in size, and with
0.6glyph transparency.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
TOOLTIPS = [("Name", "@player"), ("Team", "@team"), ("Field Goal %", "@field_goal_perc{0.2f}")]
fig = figure(x_axis_label="Assists", y_axis_label="Points", title="Shooting Guard vs Small Forward", tooltips=TOOLTIPS)
# Add glyphs for shooting guards
fig.circle(x="assists", y="points", source=shooting_guards, legend_label="Shooting Guard", ____=____, ____="____", ____=____)
# Add glyphs for small forwards
fig.circle(x="assists", y="points", source=small_forwards, legend_label="Small Forward", ____=____, ____="____", ____=____)
output_file(filename="sg_vs_sf.html")
show(fig)