BaşlayınÜcretsiz Başlayın

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".

Bu egzersiz

Interactive Data Visualization with Bokeh

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Add circle glyphs for points per game versus average assists using shooting_guards, setting size to 16 pixels, fill_color to red, and assigning 0.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.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

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)
Kodu Düzenle ve Çalıştır