類別欄的子圖
房仲業者希望你分析墨爾本各地區的房屋室內面積與土地面積如何變化。使用 column 版面配置,你可以建立兩個子圖來顯示這些關係,並以 region 作為 x 軸。
melb DataFrame 已依 region 分組,並計算出 land_area 與 building_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(____(____, ____))