Get startedGet started for free

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

View Course

Exercise instructions

  • Create TOOLTIPS, including the conference, and field_goal_perc columns as Conference, and Field Goal %, respectively.
  • Format the field_goal_perc element of TOOLTIPS to display to the nearest two decimal places.
  • Create the figure, labeling the x-axis as "Minutes" and the y-axis as "Points", including TOOLTIPS.
  • Add circle glyphs, with minutes on the x-axis against points, using source.

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)
Edit and Run Code