holoviews icon indicating copy to clipboard operation
holoviews copied to clipboard

Selection tool on datashade plot results in unexpected selection colors.

Open peterroelants opened this issue 3 years ago • 1 comments

Description of expected behavior and the observed behavior

Using the selection tool from link_selections in a datashade plot results in unexpected selection colors. The colors change when a selection is active.

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

from collections import OrderedDict
import numpy as np
import holoviews as hv
import datashader
from holoviews.operation.datashader import datashade, shade, dynspread, spread, rasterize

hv.extension('bokeh')


color_map = OrderedDict([
    ('p1', '#e41a1c'),
    ('p2', '#377eb8')
])

points_dct = OrderedDict([
    ('p1', hv.Points(np.random.randn(10000, 2), kdims=['x', 'y'], label='p1').opts(color=color_map['p1'], alpha=0.2)),
    ('p2', hv.Points(np.random.randn(10000, 2) * 2 + 1, kdims=['x', 'y'], label='p2').opts(color=color_map['p2'], alpha=0.2))
])
nd_overlay = hv.NdOverlay(points_dct, kdims=['cat'])
nd_overlay_shaded = spread(datashade(nd_overlay, aggregator=datashader.by('cat', datashader.count()), cnorm="eq_hist", color_key=color_map), px=1)
hv.selection.link_selections(nd_overlay_shaded)

Screenshots or screencasts of the bug in action

This is observable with different combinations of colors:

  • {'p1': '#e41a1c','p2': '#377eb8'}
    • Colors without selection ({'p1': '#e41a1c','p2': '#377eb8'}):
    • Colors with selection ({'p1': '#e41a1c','p2': '#377eb8'}):
  • {'p1': 'blue','p2': 'red'}
    • Colors without selection ({'p1': 'blue','p2': 'red'}):
    • Colors with selection ({'p1': 'blue','p2': 'red'}):

ALL software version info

Python implementation: CPython
Python version       : 3.9.6
IPython version      : 7.25.0

Compiler    : GCC 9.3.0
OS          : Linux
Release     : 5.10.0-1034-oem
Machine     : x86_64
Processor   : x86_64
CPU cores   : 16
Architecture: 64bit

bokeh     : 2.3.3
holoviews : 1.14.4
numpy     : 1.21.0
datashader: 0.13.0

jupyter core     : 4.7.1
jupyter-notebook : 6.4.0
qtconsole        : not installed
ipython          : 7.25.0
ipykernel        : 6.0.1
jupyter client   : 6.1.12
jupyter lab      : 3.0.16
nbconvert        : 6.1.0
ipywidgets       : 7.6.3
nbformat         : 5.1.3
traitlets        : 5.0.5

peterroelants avatar Jul 16 '21 13:07 peterroelants

Thanks. I can reproduce, but cannot immediately explain. :-/

jbednar avatar Jul 16 '21 14:07 jbednar