Adding a HoverTool
The agency is producing a blog about basketball performance by position. They want to hone in on assists and steals, giving their viewers the ability to hover over glyphs to find out who a player is, what position they play, and which team they play for.
You will convert the nba dataset, which has been preloaded, into a Bokeh source object, then add tooltips to a plot.
Este exercício faz parte do curso
Interactive Data Visualization with Bokeh
Instruções do exercício
- Import
ColumnDataSource. - Create
sourcefrom thenbaDataFrame. - Complete the creation of
TOOLTIPS, adding labels named"Position"and"Team", in that order, from the relevant columns ofsource, and addTOOLTIPSto the figure. - Add circle glyphs for
"assists"on the x-axis and"steals"on the y-axis, completing thesourceargument.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Import ColumnDataSource
from ____.____ import ____
# Create source
source = ____(data=____)
# Create TOOLTIPS and add to figure
TOOLTIPS = [("Name", "@player"), ("____", "____"), ("____", "____")]
fig = figure(x_axis_label="Assists", y_axis_label="Steals", tooltips=____)
# Add circle glyphs
fig.circle(x="____", y="____", source=____)
output_file(filename="first_tooltips.html")
show(fig)