Aan de slagGa gratis aan de slag

Big shooters

Traditionally, the tallest basketball players are in the center position, and they primarily shoot close to the basket. However, there has been a trend towards all positions shooting more three-point field goals in recent years.

The agency has a scatter plot visualizing "three_point_perc" versus "field_goal_perc" for centers and power forwards in the NBA. The dataset has been filtered for each position, and Bokeh source objects named centers and power_forwards have been preloaded for you. TOOLTIPS has also been created to display player names and average points per game.

The agency has asked you to change the plot's glyph settings to aid interpretation.

Deze oefening maakt deel uit van de cursus

Interactive Data Visualization with Bokeh

Cursus bekijken

Oefeninstructies

  • Update the glyph attribute of center_glyphs and power_forward_glyphs to 20 pixels and 10 pixels, respectively.
  • Update the fill color attribute of center_glyphs and power_forward_glyphs to red and yellow, respectively.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

fig = figure(x_axis_label="Field Goal Percentage", y_axis_label="Three Point Field Goal Percentage", tooltips = TOOLTIPS)
center_glyphs = fig.circle(x="field_goal_perc", y="three_point_perc", source=centers, legend_label="Center", fill_alpha=0.2)
power_forward_glyphs = fig.circle(x="field_goal_perc", y="three_point_perc", source=power_forwards, legend_label="Power Forward", fill_color="green", fill_alpha=0.6)

# Update glyph size
center_glyphs.____.____ = ____
power_forward_glyphs.____.____ = ____

# Update glyph fill_color
center_glyphs.____.____ = "____"
power_forward_glyphs.____.____ = "____"
output_file(filename="big_shooters.html")
show(fig)
Code bewerken en uitvoeren