There’s probably others that slipped my mind, but here are the ones I remember.
pn.bind
import panel as pn
import pandas as pd
import holoviews as hv
pn.extension("tabulator")
df = pd.DataFrame(data={"x": [0, 5, 10], "y": [0, 3, 10]})
def plot(index):
return hv.Scatter(df.iloc[index], "x", "y").opts(xlim=(0, 10), ylim=(0, 10), size=10)
tabulator = pn.widgets.Tabulator(df)
dmap = hv.DynamicMap(pn.bind(plot, tabulator.param.selection))
pn.Row(tabulator, dmap)
DynamicMap streams keyword
import panel as pn
import pandas as pd
import holoviews as hv
pn.extension("tabulator")
df = pd.DataFrame(data={"x": [0, 5, 10], "y": [0, 3, 10]})
def plot(selection):
return hv.Scatter(df.iloc[selection], "x", "y").opts(xlim=(0, 10), ylim=(0, 10), size=10)
tabulator = pn.widgets.Tabulator(df)
dmap = hv.DynamicMap(plot, streams=[tabulator.param.selection])
pn.Row(tabulator, dmap)
@pn.depends
I don’t think this works with tabulator because it returns “dataframe” type as value
import panel as pn
import pandas as pd
import holoviews as hv
pn.extension("tabulator")
df = pd.DataFrame(data={"x": [0, 5, 10], "y": [0, 3, 10]})
slider = pn.widgets.IntSlider(end=3)
@pn.depends(slider)
def plot(value):
return hv.Scatter(df.iloc[[value]], "x", "y").opts(xlim=(0, 10), ylim=(0, 10), size=10)
dmap = hv.DynamicMap(plot, kdims=["value"])
pn.Row(slider, dmap)