加入色階條
機構希望你加入一個 ColorBar,讓觀看圖表的人能理解圖形顏色變化所對應的門檻。
前一個練習中的圖形、mapper,以及圖形標記(glyphs)都已提供給你。
本練習屬於課程
使用 Bokeh 製作互動式資料視覺化
練習說明
- 匯入
ColorBar。 - 使用
mapper中相應的鍵建立color_bar,並將寬度設為 8 像素。 - 將
color_bar加到圖表右側的版面配置中。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import ColorBar
____
mapper = linear_cmap(field_name="assists", palette=RdBu8, low=min(nba["assists"]), high=max(nba["assists"]))
fig = figure(x_axis_label="Steals", y_axis_label="Assists", title="Steals vs. Assists")
fig.circle(x="steals", y="assists", source=source, color=mapper)
# Create the color_bar
color_bar = ____(color_mapper=____, width=____)
# Update layout with color_bar on the right
fig.____(____, "____")
output_file(filename="steals_vs_assists_color_mapped.html")
show(fig)