Well, here you go. I tried to make it as minimal as I could.
Hoping that Google groups support code formatting, I will copy&paste it here. If it doesn’t work, please find the .py file in this answer as well.
#!/usr/bin/env python3
from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool
from bokeh.models.tools import ResetTool, BoxZoomTool, WheelZoomTool, PanTool, SaveTool
from bokeh.io import saving
import pandas as pd
import random
colors = {0: '#b3ac00', 1: '#0eb300', 2: '#00b39d', 3: '#0011b3', 4: '#9a00b3'}
data = []
for i in range(5):
sub_sample = [(random.randint(0, 100), random.randint(0, 100), colors[i], i)
for _ in range(10)]
data.extend(sub_sample)
hover = HoverTool(tooltips=[("Position", "@x{0,0} - @y{0,0}")])
dotplot = figure(plot_width=600, plot_height=600,
x_range=(0, 120),
y_range=(120, 0),
# y_range=(0,len(ref_sequence)),
x_axis_label="Genomic coordinate",
y_axis_label="Genomic coordinate",
x_axis_location="above",
tools=[hover, ResetTool(), BoxZoomTool(),
WheelZoomTool(), PanTool(), SaveTool()],
toolbar_location="below")
for idx, color in colors.items():
sub_data = pd.DataFrame([x for x in data if x[-1] == idx], columns=['x', 'y', 'color', 'idx'])
source = ColumnDataSource(data=dict(
x=sub_data.x,
y=sub_data.y,
color=sub_data.color))
renderer = dotplot.square('x', 'y', fill_color="color", fill_alpha=0.8,
muted_color="color", muted_alpha=0,
line_color="black", line_alpha=1,
source=source, size=8,
legend="{} sub sample".format(idx))
renderer.visible = False
dotplot.x_range.bounds = (-10, 120)
dotplot.y_range.bounds = (-10, 120)
dotplot.legend.location = "top_right"
dotplot.legend.click_policy = "hide"
saving.save(dotplot, filename="mini-ex_hover.html", title="Hover-Legend-Interaction")
minimal_example.py (1.89 KB)
···
Am Montag, 16. April 2018 18:48:18 UTC+2 schrieb Bryan Van de ven:
Hi,
I’m not aware of an intentional changes. So a change could be a bug/regression, but it could also be that the previous behavior was undefined and unintentional in the first place. It’s not really possible to say much else without code to run. The most helpful thing would be to provide a complete, runnable, minimal example that reproduces the issue.
Thanks,
Bryan
On Apr 16, 2018, at 09:42, [email protected] wrote:
Hello everyone.
So, I am using bokeh since several months now for a project of mine and with the newest version, I have problems using the Hover-Tool, when I have several classes in my plot/legend.
Whenever I am hiding the first class from the plot, the Hover Tool does not work for the rest of my classes.
I am attaching two pictures, as this is the easiest way to explain my problem… please note that you cannot see the mouse in the screenshots, but believe, I put the mouse cursor
over my glyph in both screenshots
I used an older version of bokeh (not really sure whether it was 0.12.13 or 0.12.14, I am very sorry…), where I had no troubles with this Hover-Hiding-Interaction.
I searched roughly through the github issues and this google group, but to my knowledge, this wasn’t reported yet. If it was, please take my apologies for making this duplicate.
Cheers,
Kevin
–
You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/17ce085e-4d63-4d06-9002-ad486d3288ea%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<hover_hide_2.png><hover_hide_1.png>