Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Emphasizing With Hover Inspections

Give Feedback

In this lesson you will emphasize the hover actions you implemented in the last lesson. You will add an additional glyph, in this case circles instead of squares, with an initial opacity set to zero so that it is invisible until the cursor is touching it.

For even more exploration here is a link to the user guide section on Hover Inspections.


# Bokeh Libraries
from bokeh.plotting import figure, show
from import output_file
from bokeh.models import ColumnDataSource, NumeralTickFormatter, HoverTool

# Import the data
from read_nba_data import three_takers

# Output to file
            title='Three-Point Attempts vs. Percentage')

# Store the data in a ColumnDataSource
three_takers_cds = ColumnDataSource(three_takers)

#Specify the selection tools to be made available
select_tools = ['box_select', 'lasso_select', 'poly_select', 'tap', 'reset']

# Format the tooltip
tooltips = [
            ('Player', '@name'),
            ('Three-Pointers Made', '@play3PM'),
            ('Three-Pointers Attempted', '@play3PA'),
            ('Three-Point Percentage', '@pct3PM{00.0%}')   

# Create the figure
fig = figure(plot_height=400,
             x_axis_label='Three-Point Shots Attempted',
             y_axis_label='Percentage Made',
             title='3PT Shots Attempted vs. Percentage Made (min. 100 3PA), 2017-18',

# Format the y-axis tick label as percentages
fig.yaxis[0].formatter = NumeralTickFormatter(format='00.0%')

# Add square representing each player

# Configure a renderer to be used upon hover
hover_glyph ='play3PA', y='pct3PM', source=three_takers_cds,
                         size=15, alpha=0,
                         hover_fill_color='black', hover_alpha=0.5)

# Add the HoverTool to the figure
fig.add_tools(HoverTool(tooltips=tooltips, renderers=[hover_glyph]))

# Visualize

Become a Member to join the conversation.