widgetti / ipyvolume

3d plotting for Python in the Jupyter notebook based on IPython widgets using WebGL
MIT License
1.95k stars 236 forks source link

Scatter.selected always selects items 0,1,2,... instead of using the indices passed in. #373

Open mnjensen opened 3 years ago

mnjensen commented 3 years ago

I'm brand new to ipyvolume, and I think it's great. But when I set scatter.selected(), it always ends up selecting the first n scatter points, not the n points I have given indices for. For example, scatter.selected = [23, 31, 12, 15] ends up selecting points [0, 1, 2, 3].

import ipyvolume as ipv
import numpy as np
num_arrows = 50
x = np.arange(0,1, 1/num_arrows)
y = np.full((num_arrows,), 0.5)
z = np.full((num_arrows,), 0.5)
scatter = ipv.scatter(x, y, z, size=5, size_selected=8 )

# Try first
scatter.selected = [0, 1, 2, 3]

# Try second
# scatter.selected = [23, 31, 12, 15]

# Try third
# scatter.selected = [33, 16, 19, 4]

ipv.show()

All three examples above lead to 0, 1, 2, and 3 being selected.

image

My setup: ipydatawidgets==4.2.0 ipykernel @ file:///C:/ci/ipykernel_1596190155316/work/dist/ipykernel-5.3.4-py3-none-any.whl ipython @ file:///C:/ci/ipython_1604083276484/work ipyvolume==0.6.0a6 ipywidgets @ file:///tmp/build/80754af9/ipywidgets_1601490159889/work jupyter==1.0.0 jupyter-client @ file:///tmp/build/80754af9/jupyter_client_1601311786391/work jupyter-console @ file:///tmp/build/80754af9/jupyter_console_1598884538475/work jupyter-core==4.6.3 jupyterlab==2.2.6 pythreejs==2.3.0 traitlets @ file:///tmp/build/80754af9/traitlets_1602787416690/work traittypes==0.2.1

mnjensen commented 3 years ago

It looks like scatter.selected works for me in notebook, but not in jupyter lab. Does someone have advice? Thanks