使用 gridplot
房产中介想要查看墨尔本 4 个区域中,房屋面积与价格之间的关系如何变化:
"Northern"、"Western"、"Eastern" 和 "Southern"。
这是使用 gridplot 的绝佳场景,每个区域显示一个子图!
本练习是课程的一部分
使用 Bokeh 进行交互式数据可视化
练习说明
- 导入
gridplot。 - 通过按目标区域筛选
melb来创建df。 - 完成代码,为
fig添加圆形图元,x使用建筑面积列,y使用价格,数据来自source,并将legend_label设为region。 - 使用两列将子图以网格形式显示。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Import gridplot
from ____.____ import ____
plots = []
# Complete for loop to create plots
for region in ["Northern", "Western", "Southern", "Eastern"]:
df = melb.loc[melb["region"] == ____]
source = ColumnDataSource(data=df)
fig = figure(x_axis_label="Building Area (Meters Squared)", y_axis_label="Price")
fig.circle(x="____", y="____", source=____, legend_label=____)
fig.yaxis[0].formatter = NumeralTickFormatter(format="$0a")
plots.append(fig)
# Display plot
output_file(filename="gridplot.html")
show(____(____, ncols=____))