bokeh: Hover tooltip not showing for step line

ALL software version info (bokeh, python, notebook, OS, browser, any other relevant packages)

Python 3.6 Bokeh 0.12.13

Description of expected behavior and the observed behavior

Using the default hover tool I do not see the tooltip when using the step line. Switching to circle or line will result to the correct behaviour.

Complete, minimal, self-contained example code that reproduces the issue

from bokeh.plotting import figure, output_file, show

# output to static HTML file
output_file("test.html")

p = figure(plot_width=400,
           plot_height=400,
           tools='hover')

# p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5],
#          size=20,
#          color="navy",
#          alpha=0.5,
#          )

p.step([1, 2, 3, 4, 5], [6, 7, 2, 4, 5],
         color="navy",
         alpha=0.5,
         )

# p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5],
#        color="navy",
#        alpha=0.5,
#        )

# show the results
show(p)

About this issue

  • Original URL
  • State: open
  • Created 9 years ago
  • Reactions: 2
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Any news on this?

There is never any reason to comment just to ask this. If there is any new development, it would be reported here. There is currently much work than people to do it. New help/contributors is certainly appreciated and the only way things can go faster.

Sure! Just add a dot plot to your step plot. Hover tool will work on the dots and this workaround is fine for me.

While this is clearly a workaround and it has its limitations, I agree that this is a great idea. I have tweaked it a bit:

import pandas as pd
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
from bokeh.models import ColumnDataSource, HoverTool
output_notebook()

x = [1,2,3,4,5,6,7,8,9]
y = [0,1,0,1,0,1,1,0,0]

TOOLTIPS = [
  ("x", "@x"),
  ("y", "@y")
]

cds = ColumnDataSource(pd.DataFrame({"x":x, "y":y}))

p1 = figure(height=300, sizing_mode="stretch_width", title="Step Hover Test")
p1.step(x="x", y="y", mode="after", source=cds)

# Helper to show hover with step plot
dots = p1.dot(x="x", y="y", source=cds)

hover_tool = HoverTool(tooltips=TOOLTIPS, mode='vline')
p1.add_tools(hover_tool)

show(p1)

This increases the hit area of the HoverTool to not just the dot but anywhere on the vertical line passing thru the dot

provide an example

Sure! Just add a dot plot to your step plot. Hover tool will work on the dots and this workaround is fine for me.

import pandas as pd
from bokeh.plotting import figure, show
from bokeh.io import output_notebook
from bokeh.models import ColumnDataSource
output_notebook()

x = [1,2,3,4,5]
y = [0,1,0,1,0]

TOOLTIPS = [
  ("x", "@x"),
  ("y", "@y")
]

cds = ColumnDataSource(pd.DataFrame({"x":x, "y":y}))

p1 = figure(height=300, sizing_mode="stretch_width", title="Step Hover Test", tooltips=TOOLTIPS)
p1.step(x="x", y="y", mode="after", source=cds)

# Helper to show hover with step plot
p1.dot(x="x", y="y", source=cds)

show(p1)

Image

I would like to express interest in this feature as well. We are trying to visualize histograms with many bins (>10k) with bokeh. bars/boxes seem to perform way worse and are not as feature-rich in general than the step glyph, it seems. We prefer the step glyph over the line, since, when zoomed in close, it is still clear what the size of a single bin is. However, due to the hover feature, we are using line now.