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.
Este exercício faz parte do curso
Interactive Data Visualization with Bokeh
Instruções do exercício
- Create
TOOLTIPS, including theconference, andfield_goal_perccolumns asConference, andField Goal %, respectively. - Format the
field_goal_percelement ofTOOLTIPSto 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
minuteson the x-axis againstpoints, usingsource.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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)