Adding a color bar
The agency has requested you include a ColorBar so people viewing the plot will understand the thresholds at which the glyph color changes.
The figure from the previous exercise, a mapper, and glyphs, have all been provided for you.
Este exercício faz parte do curso
Interactive Data Visualization with Bokeh
Instruções do exercício
- Import
ColorBar. - Create
color_barusing the relevant key frommapper, and set width to 8 pixels. - Add
color_barto the figure's layout on the right-hand side.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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)