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"
.
This exercise is part of the course
Interactive Data Visualization with Bokeh
Exercise instructions
- Add circle glyphs for points per game versus average assists using
shooting_guards
, settingsize
to 16 pixels,fill_color
to red, and assigning0.2
to 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.6
glyph transparency.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
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)