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.

HoverTool showing canvas coordinates not data coordinates

See original GitHub issue

I don’t think this is mentioned in the other hover tool issues, but I might have missed it.

Using $x, $y in HoverTool displays the canvas coordinates, not the data coordinates as I believe it is supposed to. Using $sx, $sy displays the canvas coordinates as well.

e.g.

from bokeh.plotting import figure, output_file, show
from bokeh.models import HoverTool

output_file("hover.html")

hover = HoverTool(
            tooltips=[
                ("index", "$index"),
                ("data (x,y)", "($x, $y)"),
                ("canvas (x,y)", "($sx, $sy)")
                ])

TOOLS = [hover]

p = figure(plot_width=400, plot_height=400, title=None, tools=TOOLS)

p.circle([1, 2, 3, 4, 5], [2, 5, 8, 2, 7], size=10)

show(p)

produces

screen shot 2016-07-22 at 7 46 20 am

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bgbgcommented, Jul 27, 2016

A quick workaround: when referencing the column names using the “@” notation, the tooltips are presented correctly

from bokeh.plotting import figure, output_file, show
from bokeh.models import HoverTool

hover = HoverTool(
            tooltips=[
                ("index", "$index"),
                ("data (using $) (x,y)", "($x, $y)"),
                ("data (using @) (x,y)", "(@x, @y)"),
                ("canvas (x,y)", "($sx, $sy)")
                ])

TOOLS = [hover]
p = figure(plot_width=400, plot_height=400, title=None, tools=TOOLS)
p.circle([1, 2, 3, 4, 5], [2, 5, 8, 2, 7], size=10)
show(p)

image

0reactions
bryevdvcommented, Jun 9, 2017

@w1res there might be something specific to lines which are more complicated due to their connectivity. However, please open a new issue so this can be tracked and prioritized independently.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Bokeh - HoverTool: Coordinates for the figure and not ...
The hover tool only displays when a glyph is "hit" by the cursor. The reason for this is that field specifiers such as...
Read more >
Configuring plot tools — Bokeh 2.4.3 Documentation
y-coordinate under the cursor in data space. $sx. x-coordinate under the cursor in screen (canvas) space. $sy.
Read more >
Plotting with Datashader - | notebook.community
Below is a Datashader image being shown within Bokeh. This relies on the InteractiveImage function to tie the two together. You can also...
Read more >
Realtime Flight Tracking with Pandas and Bokeh - Geodose
The coordinate system is not match to each other, so we can not plot the aircraft position directly on the map. The aircraft...
Read more >
Display Info When You Hover To A Data Point In Matplotlib ...
This is one of the most requested topics so I thought I would finally make a video showing how to implement the feature...
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