question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bokeh HoverTool performance on many points selected by mouse

See original GitHub issue

Hello,

I noticed a performance issue when dealing with many points being selected, intentionally or accidentally, by hovertool mouse. In my original use case I had a categorical x-axis with a jitter. Some categories had more or less scatter then others and at the default view those closely clustered points tended to show a noticeable performance degradation compared to other areas of my plot with only a few overlapping points.

The code example below replicates the performance issues when hovering over the cluster of points in chrome using Bokeh 0.12.9

output_file("Bokeh_hover_issue.html")
_tools_to_show = 'box_zoom,pan,save,hover,resize,reset,tap,wheel_zoom' 

n=1000
source = ColumnDataSource({'x':[1]+[2 for i in range(n)],
                           'y':[1]+[2 for i in range(n)],
                           'c':['string' for _ in range(n+1)] })
p = figure(plot_width=300, plot_height=300, tools=_tools_to_show,
       title="Hover tool tip slow down on multiple points")
p.circle(x=jitter('x', width=0.05),
         y=jitter('y', width=0.05),
         source=source, alpha=0.3,size=12)

hover = p.select(dict(type=HoverTool))
hover.tooltips=[('c',"@c")]

save(p)

image

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
rochesebcommented, Sep 27, 2017

If you use the bokeh server you can do that with a custom template.

myapp/main.py

import bokeh
from bokeh.io import curdoc
from bokeh.plotting import figure

from random import random

fig = figure(tools='hover,wheel_zoom,pan')

x = range(10**5)
y = [random() for i in x]

fig.scatter(x,y)

curdoc().add_root(fig)

myapp/templates/index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>hover</title>
    {{ bokeh_css }}
    {{ bokeh_js }}
  </head>
  <body>
    <style type="text/css">
      {% include 'styles.css' %}
    </style>
    {{ plot_div|indent(8) }}
    {{ plot_script|indent(8) }}
  </body>
</html>

myapp/templates/styles.css

.bk-tooltip>div:not(:first-child) {
	display:none;
}

If you save a static html file you can just add the style tag to the file yourself.

0reactions
bryevdvcommented, Feb 7, 2020

#9087 is a dupe of this / how this will be handled, but more current, so closing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuring plot tools — Bokeh 2.4.3 Documentation
The tap selection tool allows you to select single points by clicking the left mouse button, or tapping with a finger. After a...
Read more >
Bokeh hovertools which run arbitrary python code
Namely: Is it possible for hover tools to run python code on the fly, such that they can display plots of the data...
Read more >
Interactive Data Visualization with Bokeh - Trenton McKinney
You will create your first plots, learn about different data formats Bokeh understands, and make visual customizations for selections and mouse hovering.
Read more >
The HoverTool | Python - DataCamp
Here is an example of The HoverTool: . ... Interactive Data Visualization with Bokeh. George Boorman. Core Curriculum Manager, DataCamp ...
Read more >
bokeh - Water Programming: A Collaborative Research Blog
from bokeh.models.tools import HoverTool #for importing the hover tool ... the same points will be selected in the other views.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found