Formatting the HoverTool
Now you've built a plot with a HoverTool
, it's time to go one step further by formatting how the information is presented.
The agency has asked for a plot of average minutes versus average points per game. They would like the HoverTool to identify the player's name, their conference, and their field goal percentage rounded to the nearest 2 decimal places.
This exercise is part of the course
Interactive Data Visualization with Bokeh
Exercise instructions
- Create
TOOLTIPS
, including theconference
, andfield_goal_perc
columns asConference
, andField Goal %
, respectively. - Format the
field_goal_perc
element ofTOOLTIPS
to display to the nearest two decimal places. - Create the figure, labeling the x-axis as
"Minutes"
and the y-axis as"Points"
, includingTOOLTIPS
. - Add circle glyphs, with
minutes
on the x-axis againstpoints
, usingsource
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create TOOLTIPS
TOOLTIPS = [("Name", "@player"),
("____", "____"),
("____", "____")]
# Add TOOLTIPS to figure
fig = figure(x_axis_label="____", y_axis_label="____", tooltips=____)
# Add circle glyphs
fig.circle(x="____", y="____", source=____)
output_file(filename="formatted_hovertool.html")
show(fig)