First of all, thanks for Bokeh. I like it for both its richness and its good performance.
I have written code for drawing several Bokeh figures, arranged in a gridplot
. I’ve gotten this working in vscode
by embedding it in a Panel pn.pane.Bokeh(...)
. All versions are the latest:
Bokeh 3.1.1
jupyter_bokeh 3.0.7
Panel 1.1.1
vscode 1.79.2
All that does work quite well, and I am able to catch Tap events in python code using a callback:
def tap_callback(event):
print(f"model={event.model} x={event.x} "
f"y={event.y} sx={event.sx} sy={event.sy}")
works and prints out e.g.
model=figure(id='87811164-101d-463f-9491-fafa3085d95b', ...)
x=-0.793488401391503
y=1.5217391304347825
sx=116
sy=533
Now, the figures I created have a categorical y-axis where each tick shows a string (actually a feature name). I created it like this:
_ = fig.hbar(source=s, y='feature', right='correlation', color="#00330033", width=2)
and it does display the y-axis correctly with names appearing along the ticks.
I need to translate the numerical y-coordinate as above to the feature name. I am new to Bokeh, so I searched all the docs as far as I am able and was not able to find an answer. Am I doing something unusual? Is this easy or difficult?
I am hoping for some functions, perhaps available on the event object or its sub-objetcs (the figure object?), that would do something along the lines of:
def tap_callback(event):
name_tapped = event.model.get_name_from_coordinate(event.y)
print(name_tapped)
Many thanks!
GPN