開始使用免費開始

類別欄的子圖

房仲業者希望你分析墨爾本各地區的房屋室內面積與土地面積如何變化。使用 column 版面配置,你可以建立兩個子圖來顯示這些關係,並以 region 作為 x 軸。

melb DataFrame 已依 region 分組,並計算出 land_areabuilding_area 的平均值。這些資料已設定為名為 source 的 Bokeh 資料物件,並替你預先載入。

本練習屬於課程

使用 Bokeh 製作互動式資料視覺化

檢視課程

練習說明

  • 從對應的 Bokeh 模組匯入 column
  • building_size 中加入直條圖圖元,繪製每個 "region""building_area"
  • land_size 中加入直條圖圖元,呈現每個 "region""land_area"
  • 產生名為 "my_first_column.html" 的 HTML 檔,並完成 show() 的呼叫以同時顯示兩個子圖。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import column
from ____.____ import ____
regions = ["Eastern", "Southern", "Western", "Northern"]
building_size = figure(x_axis_label="Region", y_axis_label="Building Size (Meters Squared)", 
                       x_range=regions)
land_size = figure(x_axis_label="Region", y_axis_label="Land Size (Meters Squared)", 
                   x_range=regions)

# Add bar glyphs
building_size.____(x="____", top="____", source=____)
land_size.____(x="____", top="____", source=____)

# Generate HTML file and display the subplots
output_file(filename="____")
show(____(____, ____))
編輯並執行程式碼