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

Lasso Select for Linked Selection is broken for Bar charts #6248

Open ahuang11 opened 1 month ago

ahuang11 commented 1 month ago

Link selections with bar charts seem broken:

import numpy as np
import pandas as pd
import holoviews as hv

from holoviews.util.transform import dim
from holoviews.selection import link_selections
from holoviews.operation import gridmatrix
from holoviews.operation.element import histogram
from holoviews import opts
from bokeh.sampledata.autompg import autompg
autompg

hv.extension('bokeh', 'plotly', width=100)

autompg_ds = hv.Dataset(autompg, ['yr', 'name', 'origin'])

mopts = opts.Points(size=2, tools=['box_select','lasso_select'], active_tools=['box_select'])
w_accel_scatter = hv.Scatter(autompg_ds, 'weight', 'accel')
mpg_hist = histogram(autompg_ds, dimension='mpg', normed=False).opts(color="green")
violin = hv.Violin(autompg_ds, [], 'hp')

mpg_ls = link_selections.instance()
mpg_ls(w_accel_scatter + mpg_hist + violin)

https://github.com/holoviz/holoviz/assets/15331990/3aaa03a3-3910-4867-9d47-2465ece13253

hoxbro commented 1 month ago

Versions? Does it work outside vscode?

Is it related to the chart PR?

philippjfr commented 1 month ago

Can't reproduce this one.

ahuang11 commented 1 month ago

Actually only lasso select doesn't work using latest version of HoloViews on JupyterLab

hoxbro commented 1 month ago

latest version of HoloViews

What is the latest? Main or the latest release.

philippjfr commented 1 month ago

Main

hoxbro commented 1 month ago

Seems to work if you update hv.Scatter to hv.Points: hv.Points(autompg_ds, kdims=['weight', 'accel']). Though it does not work if I change the opts to Scatter. image

hv.show_versions ``` yaml Python : 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:38:13) [GCC 12.3.0] Operating system : Linux-6.8.0-76060800daily20240311-generic-x86_64-with-glibc2.35 Panel comms : default holoviews : 1.19.0a4.dev6+ge2a23d1c6 bokeh : 3.4.1 colorcet : 3.1.0 cudf : - dask : 2024.5.1 datashader : 0.16.2rc1 geoviews : 1.12.0.post3+geed196d hvplot : 0.10.1.dev2+g23d9f0c.d20240530 ibis-framework : 9.0.0 IPython : 8.24.0 jupyter_bokeh : 4.0.4 jupyterlab : 4.2.1 matplotlib : 3.8.4 networkx : 3.3 notebook : 7.2.0 numba : 0.59.1 numpy : 1.26.4 pandas : 2.2.2 panel : 1.5.0a3.post1.dev19+g59c2be2e.d20240603 param : 2.1.1a1.dev3+g7c9d7c6.d20240530 pillow : 10.3.0 plotly : 5.22.0 pyarrow : 16.1.0 pyviz_comms : 3.0.2 scikit-image : 0.22.0 scipy : 1.13.1 spatialpandas : 0.4.10 streamz : 0.6.4 tsdownsample : 0.1.3 xarray : 2024.5.0 ```
philippjfr commented 1 month ago

Ah, indeed, it's actually intended this way but I'm not sure it's the right choice for Scatter in the end. Certainly we shouldn't be enabling lasso if the element doesn't support it.