Session Ready
Exercise

Adding a hover tooltip

Working with the HoverTool is easy for data stored in a ColumnDataSource.

In this exercise, you will create a HoverTool object and display the country for each circle glyph in the figure that you created in the last exercise. This is done by assigning the tooltips keyword argument to a list-of-tuples specifying the label and the column of values from the ColumnDataSource using the @ operator.

The figure object has been prepared for you as p.

After you have added the hover tooltip to the figure, be sure to interact with it by hovering your mouse over each point to see which country it represents.

Instructions
100 XP
  • Import the HoverTool class from bokeh.models.
  • Use the HoverTool() function to create a HoverTool object called hover and set the tooltips argument to be [('Country','@Country')].
  • Use p.add_tools() with your HoverTool object to add it to the figure.