阻攻 vs. 籃板
你在一家體育媒體代理商工作,專門製作包含部落格、分析與視覺化等資料新聞內容,重點放在籃球。nba 資料集已經為你預先載入,其中包含 2017 賽季球員的場均統計,以及其所屬球隊、分區,還有用來表示得分能力的標籤。
該代理商希望你產生一個散佈圖,顯示阻攻與籃板之間的關係。
本練習屬於課程
使用 Bokeh 製作互動式資料視覺化
練習說明
- 從相關的兩個 Bokeh 類別中匯入
figure、output_file和show。 - 建立一個新的圖表
fig,並用關鍵字參數將 x 軸標示為"Blocks per Game"、y 軸標示為"Rebounds per Game"。 - 加入圓形圖元,將
x設為nba["blocks"],y設為nba["rebounds"]。 - 呼叫函式將圖表輸出為 HTML 檔案,將
filename設為"my_first_plot.html",並顯示圖表。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import required libraries
from ____.____ import ____
from ____.____ import ____, ____
# Create a new figure
fig = ____(x_axis_label="____", y_axis_label="____")
# Add circle glyphs
fig.____(x=____["____"], y=____["____"])
# Call function to produce html file and display plot
____(filename="____")
____(____)