ComenzarEmpieza gratis

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 ejercicio forma parte del curso

Interactive Data Visualization with Bokeh

Ver curso

Instrucciones del ejercicio

  • Import ColorBar.
  • Create color_bar using the relevant key from mapper, and set width to 8 pixels.
  • Add color_bar to the figure's layout on the right-hand side.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# 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)
Editar y ejecutar código