holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.66k stars 396 forks source link

Avoid that tap in overlay with image will dim the image entirely #6254

Closed GeoVizNow closed 1 month ago

GeoVizNow commented 1 month ago

Here is a reporting of an issue that has appeared lately. Not sure exactly when, but maybe after bokeh 3.

ALL software version info

holoviews: 1.18.3 panel: 1.3.8 bokeh: 3.3.4 hvplot: 0.10.0

Description of expected behavior and the observed behavior

In an overlay with say rectangles and image a tap tool should not dim the image when a rectangle is tapped.

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

import numpy as np
import holoviews as hv
from holoviews import opts
import hvplot.pandas
import bokeh
import panel as pn
hv.extension('bokeh')

ls = np.linspace(0, 10, 200)
xx, yy = np.meshgrid(ls, ls)

bounds=(-1,-1,10,10)
img = hv.Image(np.sin(xx)*np.cos(yy), bounds=bounds)

rectangles = hv.Rectangles([(0, 0, 1, 1), (2, 3, 4, 6), (0.5, 2, 1.5, 4), (2, 1, 3.5, 2.5)]).redim(x0='x', y0='y')

img.opts(alpha=1., visible=True) * rectangles.opts(tools=['tap'], alpha=.6, color='red')

Stack traceback and/or browser JavaScript console output

Screenshots or screencasts of the bug in action

2024-06-03_09-19-21

hoxbro commented 1 month ago

This is a Bokeh issue. See https://github.com/bokeh/bokeh/issues/13678.

Try to upgrade Bokeh to 3.4.

hoxbro commented 1 month ago

This is no longer a problem. Please reopen the issue if you still see the problem after upgrading to Bokeh 3.4.

GeoVizNow commented 1 month ago

Thanks for pointing this out so quickly. I upgraded to bokeh==3.4.1. Then the image did not disappear/dim. However, having set the 'alpha'=.6 I was confused for some time as the 'tap' selection did not seem to give any visual response. Then I modified the nonselection_alpha=.2 and the effect of the tap selection(s) was clear by partial transparency of other items. Also by not setting any 'alpha' the response was clearly vivible. Not sure if me setting the 'alpha' should override the initial 'nonselection_alpha'(?) Anyway this works now. Thanks again!

ls = np.linspace(0, 10, 200)
xx, yy = np.meshgrid(ls, ls)

bounds=(-1,-1,10,10)
img = hv.Image(np.sin(xx)*np.cos(yy), bounds=bounds)

rectangles = hv.Rectangles([(0, 0, 1, 1), (2, 3, 4, 6), (0.5, 2, 1.5, 4), (2, 1, 3.5, 2.5)]).redim(x0='x', y0='y')

overlay = img.opts(alpha=1., visible=True) * rectangles.opts(
    tools=['tap'],
    alpha=.6,
    nonselection_alpha=.2,
    color='red')
GeoVizNow commented 1 month ago

Just noting there is some behavior that is different from what I recall for tap:

It seems the selection is automatically implementing 'append' in terms of visuals selected, but the tap stream contents is only reporting one coordinate at the time. Not sure if this is as expected.

image

hoxbro commented 1 month ago

This is a behavior change in Bokeh 3.4, see https://github.com/bokeh/bokeh/issues/13831. Will be reverted in 3.5 and likely also backported to 3.4.

GeoVizNow commented 1 month ago

Thanks a lot for the info :-)

hoxbro commented 1 month ago

No problem, glad to help :+1: