Nice little interactive data widget with accordion example.
import panel as pn
import param as pm
import numpy as np
import pandas as pd
import hvplot.pandas
class SimplePlotExample(pm.Parameterized):
x = pm.Integer(default=50, bounds=(1, 100))
@pm.depends('x')
def plot(self):
# Generate data
df = pd.DataFrame({
'x': np.linspace(0, self.x, 100),
'y': np.linspace(0, self.x, 100)**2
})
# Plot
return df.hvplot.line('x', 'y', grid=True, title='y = x^2 Plot')
def view(self):
view = pn.Column(
"""
## Accordion Template Example
""",
pn.Accordion(
('Plot', pn.panel(self.plot)),
('Parameter', pn.Param(self.param, widgets={'x': {'type': pn.widgets.IntSlider, 'name': 'X Value'}})),
),
)
# Open by default
view[1].active = list(range(len(view[1])))
return view
# Create the example instance and serve
example = SimplePlotExample()
example.view()