Updating scatter points#
This notebook will show examples on how to update positions and colors of scatter points using interactive widgets.
[1]:
import plopp as pp
import scipp as sc
import ipywidgets as ipw
%matplotlib widget
a = pp.Node(pp.data.scatter())
b = pp.Node(pp.data.scatter(seed=2) * 10.0)
slider = ipw.FloatSlider(
min=0,
max=60,
value=30,
description='Position of orange group',
style={'description_width': 'initial'},
layout={'width': '500px'},
)
slider_node = pp.widget_node(slider)
@pp.node
def move(da, x):
out = da.copy(deep=False)
out.coords['x'] = da.coords['x'] + sc.scalar(x, unit=da.coords['x'].unit)
return out
move_node = move(da=b, x=slider_node)
f = pp.scatterfigure(a, move_node, cbar=False)
f.bottom_bar.add(slider)
f.canvas.xrange = [-40, 100]
f
[1]:
[2]:
pp.show_graph(f)
[2]: