Highlighting by glyph size
The sports media agency you worked with previously has contacted you as they would like some more visualizations! They've requested a plot that uses different size glyphs to communicate about player statistics.
The nba
dataset has been preloaded for you, and subset into two DataFrames, east
and west
, for the East and West conferences. You'll create a plot visualizing points against assists, with the glyph size depending on how many blocks per game a player averages.
This exercise is part of the course
Interactive Data Visualization with Bokeh
Exercise instructions
- Use
east
andwest
to createeast_sizes
andwest_sizes
—dividingeast["blocks"]
andwest["blocks"]
by5
, respectively. - Add circle glyphs to
fig
representing points versus assists foreast
; use a blue fill color, afill_alpha
of0.3
, a legend label of"East"
, and set theradius
toeast_sizes
. - Repeat the above for
west
, but fill in red, set a legend label of"West"
, and usewest_sizes
to change the glyph size.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create sizes
east_sizes = ____
west_sizes = ____
fig = figure(x_axis_label="Assists", y_axis_label="Points", title="NBA Points, Blocks, and Assists by Conference")
# Add circle glyphs for east
____
# Add circle glyphs for west
____
output_file(filename="size_contrast.html")
show(fig)