Download this notebook from GitHub (right-click to download).

import panel as pn
import param


The panel.Param pane allows customizing the widgets, layout and style of the parameters of a param.Parametrized Class.


The basic parameters are:

  • object (param.parameterized.Parameters): The param attribute of a param.Parameterized Class

  • parameters (List[str]): A list identifying the subset of parameters to include in the Pane.

  • widgets (Dict): A Dictionary specifying which parameters and widgets to use for a given parameter. You can also specify widget attributes.

The more advanced parameters which give you more control are:

  • default_layout (ClassSelector): A layout like Column, Row, etc. or a Custom GridBox.

  • display_threshold (float): Parameters with precedence below this value are not displayed.

  • expand (bool): Whether parameterized subobjects are expanded or collapsed on instantiation.

  • expand_button (bool): Whether to add buttons to expand and collapse sub-objects.

  • expand_layout (layout): Layout to expand sub-objects into.

  • name (str): The title of the pane.

  • show_labels (bool): Whether or not to show labels

  • show_name (bool): Whether or not to show the name of the Parameterized Class

For more layout and styling related parameters see the customization user guide.

For an alternative example of using panel.Param see the parameters user guide.

Model building#

Let’s build a model of a cycling Athlete and her PowerCurve.

The PowerCurve is a recording of her maximum power output in Watt per kg for fixed durations of time.

import datetime
import pandas as pd
import hvplot.pandas

DATE_BOUNDS = (, 1, 1),

class PowerCurve(param.Parameterized):
    ten_sec = param.Number(1079)
    ten_sec_date = param.Date(, 8, 21), bounds=DATE_BOUNDS)
    one_min = param.Number(684)
    one_min_date = param.Date(, 8, 31), bounds=DATE_BOUNDS)
    ten_min = param.Number(419)
    ten_min_date = param.Date(, 9, 22), bounds=DATE_BOUNDS)
    twenty_min = param.Number(398)
    twenty_min_date = param.Date(, 9, 22), bounds=DATE_BOUNDS)
    one_hour = param.Number(319)
    one_hour_date = param.Date(, 8, 6), bounds=DATE_BOUNDS)
    @param.depends("ten_sec", "one_min", "ten_min", "twenty_min", "one_hour")
    def plot(self):
        data = {
            "duration": [10 / 60, 1, 10, 20, 60],
            "power": [self.ten_sec, self.one_min, self.ten_min, self.twenty_min, self.one_hour],
        dataframe = pd.DataFrame(data)
        line_plot = dataframe.hvplot.line(
            x="duration", y="power", line_color="#007BFF", line_width=3, responsive=True,
        scatter_plot = dataframe.hvplot.scatter(
            x="duration", y="power", marker="o", size=6, color="#007BFF", responsive=True
        fig = line_plot * scatter_plot
        gridstyle = {"grid_line_color": "black", "grid_line_width": 0.1}
        fig = fig.opts(
            yticks=list(range(0, 1600, 200)),
            ylim=(0, 1500),
        return fig

class Athlete(param.Parameterized):
    name_ = param.String("P.A. Nelson")
    birthday = param.Date(, 9, 17), bounds=DATE_BOUNDS)
    weight = param.Number(default=82, bounds=(20,300))
    power_curve = param.ClassSelector(class_=PowerCurve, default=PowerCurve())
athlete = Athlete()

The pn.Param pane can be used to view and edit the models.

Try clicking the ... button. This will expand the PowerCurve if running in an interactive notebook.


The default Name and Birthday widgets are slow to use. So let’s change them to a DatePicker and a LiteralInput.

pn.Param(athlete, widgets={"birthday": pn.widgets.DatePicker, "weight": pn.widgets.LiteralInput})

Let’s expand the power curve by default:

        "birthday": pn.widgets.DatePicker, 
        "weight": pn.widgets.LiteralInput
    }, expand=True)

Now let’s try to display the Name and Birthday only and in a Row.

    widgets={"birthday": pn.widgets.DatePicker},
    parameters=["name_", "birthday"],

Let’s customize the view of the Athlete some more.

athlete_view = pn.Param(
        "birthday": pn.widgets.DatePicker, 
        "weight": {"type": pn.widgets.LiteralInput, "width": 100}
    parameters=["name_", "birthday", "weight"],

Let’s take a look at the PowerCurve.


The PowerCurve layout is not that tidy. Let’s change the layout to two columns.

def new_class(cls, **kwargs):
    "Creates a new class which overrides parameter defaults."
    return type(type(cls).__name__, (cls,), kwargs)

power_curve_columns_view = pn.Param(
    default_layout=new_class(pn.GridBox, ncols=2),
    widgets = {
        "ten_sec_date": pn.widgets.DatePicker, 
        "one_min_date": pn.widgets.DatePicker, 
        "ten_min_date": pn.widgets.DatePicker,
        "twenty_min_date": pn.widgets.DatePicker, 
        "one_hour_date": pn.widgets.DatePicker


Let’s put a plot of the PowerCurve in the mix.

sections = {'InputFiles': ['dirs', 'files'], 'Field': ['grps', 'varns']}

def update(target, event):
    target.set_param(options=sections[], value=sections[][0])

sel = pn.widgets.Select(options=list(sections.keys()))
rad = pn.widgets.RadioButtonGroup(options=sections[sel.value]), callbacks={'value': update})

pn.Column(sel, rad)
power_curve_view = pn.Row(

And finally, let’s put things together.

    pn.pane.Markdown("### Athlete"), 
    pn.pane.Markdown("#### Power Curve"), 

Disabling continuous updates for slider widgets#

When a function takes a long time to run and depends on a parameter, realtime feedback can be a burden instead of being helpful.

Therefore if a slider widget is used for a parameter and you have a function which takes long time to calculate, you can set the throttled keyword in the panel.param.widgets to True for the given parameter. This will then first run the function after the release of the mouse button of the slider.

An example can be seen below where two parameters is connected to two sliders, one with and one without throttled enabled.

class A(param.Parameterized):
    without_throttled_enabled = param.Range(
        default=(100, 250),
        bounds=(0, 250),

    with_throttled_enabled = param.Range(
        default=(100, 250),
        bounds=(0, 250),

    def __init__(self, **params):
        widgets = {
            "without_throttled_enabled": pn.widgets.IntRangeSlider,
            "with_throttled_enabled": {
                "type": pn.widgets.IntRangeSlider,
                "throttled": True,
        self.controls = pn.Param(self, widgets=widgets)

    def calculation(self):
        return self.without_throttled_enabled, self.with_throttled_enabled

a = A()
pn.Column(a.controls, a.calculation)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).