开始使用免费开始使用

面积、位置与价格

接下来,中介公司希望了解房价与房屋面积以及与中央商务区(CBD)的距离之间的关系。

在这里,两个图的 y 轴单位相同,因此将子图并排成一行是合适的选择。source 已使用 melb 数据集构建为一个 Bokeh 对象,并已为您预加载。

本练习是课程的一部分

使用 Bokeh 进行交互式数据可视化

查看课程

练习说明

  • 从相应的 Bokeh 模块中导入 row
  • 为两个图都添加圆形图元:在 building_size 中绘制 y 轴为 "price"、x 轴为 "building_area";在 distance 中绘制 y 轴为 "price"、x 轴为 "distance"
  • 将两个图的 y 轴更新为 $0a 的显示格式,以百万美元为单位。
  • 完成 show() 的调用以显示两个子图。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Import row
from ____.____ import ____
building_size = figure(x_axis_label="Building Area (Meters Squared)", y_axis_label="Sales")
distance = figure(x_axis_label="Distance from CBD (km)", y_axis_label="Sales")

# Add circle glyphs
building_size.circle(x="____", y="____", source=____)
distance.circle(x="____", y="____", source=____)

# Update the y-axis format for both figures
building_size.____[____].____ = ____(____="____")
distance.____[____].____ = ____(____="____")

# Display the subplots
output_file(filename="my_first_row.html")
show(____(____, ____))
编辑并运行代码