Linking Tabulator with a HV plot

Hi @eudoxos

Welcome to the community. The trick is to bind to the selection parameter. Unfortunately the selected_dataframe is just a normal property and not a parameter that can be bound to.

import panel as pn
import hvplot.pandas
import pandas as pd
import numpy as np

pn.extension(sizing_mode="stretch_width")

lookup = {0: "A", 1: "B", 2: "C"}

pars = pd.DataFrame(
    {"name": ["A", "B", "C"], "period": [1, 0.5, 0.3], "amplitude": [0.3, 0.4, 0.1]}
)
xx = np.linspace(0, 1, 100)
arr = pars["amplitude"].to_numpy() * np.sin(
    np.outer(2 * np.pi * xx, 1.0 / pars["period"].to_numpy())
)
curves = pd.DataFrame(dict([(pars["name"][i], arr[:, i]) for i in range(0, 3)]), index=xx)


def compute_plot(selection):
    if not selection:
        selection_df = curves
    else:
        selection = [lookup[i] for i in selection]
        selection_df = curves[selection]
    return selection_df.hvplot(grid=True)


tabedit = pn.widgets.Tabulator(
    value=pars, show_index=False, selectable=True, disabled=True, theme="site", height=140
)
plot = pn.bind(compute_plot, selection=tabedit.param.selection)

pn.template.FastListTemplate(
    site="Awesome Panel", title="Table Selection", main=[tabedit, plot]
).servable()