Aan de slagGa gratis aan de slag

Free throw percentage by position

The agency has asked for one final plot from you. You'll use factor_cmap to build a scatter plot visualizing free throw percentage versus average points, displaying each player position as a different color.

A source object called source has been created from the nba dataset and preloaded for you. The variable TOOLTIPS, containing the name of the player, has also been created, so it can be viewed when hovering the mouse over the plot.

Deze oefening maakt deel uit van de cursus

Interactive Data Visualization with Bokeh

Cursus bekijken

Oefeninstructies

  • Import Category10_5 and factor_cmap.
  • Create positions, a list containing "PG", "SG", "SF", "PF", and "C".
  • Pass "position" to the legend_field argument and complete the fill_color argument within fig.circle().

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import modules
____
____

# Create positions
positions = ["____", "____", "____", "____", "____"]
fig = figure(x_axis_label="Free Throw Percentage", y_axis_label="Points", title="Free Throw Percentage vs. Average Points", tooltips=TOOLTIPS)

# Add circle glyphs
fig.circle(x="free_throw_perc", y="points", source=source, legend_field="____", fill_color=factor_cmap("____", palette=____, factors=____))

output_file(filename="average_points_vs_free_throw_percentage.html")
show(fig)
Code bewerken en uitvoeren