开始使用免费开始使用

按位置划分的罚球命中率

机构还向您索要最后一张图。您将使用 factor_cmap 构建一个散点图,展示罚球命中率与场均得分的关系,并用不同颜色表示不同的球员位置。

一个名为 source 的数据源对象已根据 nba 数据集创建并为您预加载。还提供了变量 TOOLTIPS,其中包含球员姓名,鼠标悬停在图上时即可查看。

本练习是课程的一部分

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

查看课程

练习说明

  • 导入 Category10_5factor_cmap
  • 创建 positions,其为包含 "PG""SG""SF""PF""C" 的列表。
  • fig.circle() 中,将 "position" 传给 legend_field 参数,并补全 fill_color 参数。

交互式实操练习

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

# Import modules
____
____

# Create positions
positions = ["____", "____", "____", "____", "____"]
fig = figure(x_axis_label="Free Throw Percentage", y_axis_label="Points", title="Free Throw Percentage vs. Average Points", tooltips=TOOLTIPS)

# Add circle glyphs
fig.circle(x="free_throw_perc", y="points", source=source, legend_field="____", fill_color=factor_cmap("____", palette=____, factors=____))

output_file(filename="average_points_vs_free_throw_percentage.html")
show(fig)
编辑并运行代码