LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Interactive Data Visualization with Bokeh

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# 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)
Code bearbeiten und ausführen