开始使用免费开始使用

使用 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=____))
编辑并运行代码