Distribution Tabs#

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

import panel as pn
import numpy as np
import holoviews as hv


This example demonstrates how to plot several different types of outputs in a Tabs Panel, using a reactive function that depends on some widget state to update the tab contents whenever one of the dependencies changes.

distributions = {
    'NORMAL': np.random.normal,
    'UNIFORM': np.random.uniform,
    'LOG-NORMAL': np.random.lognormal,
    'EXPONENTIAL': np.random.exponential

checkboxes = pn.widgets.ToggleGroup(options=distributions, behavior='radio', button_type="success")
slider = pn.widgets.IntSlider(name='Number of observations', value=500, start=0, end=2000)

@pn.depends(checkboxes.param.value, slider.param.value)
def tabs(distribution, n):
    values = hv.Dataset(distribution(size=n), 'values')
    return pn.Tabs(
        ('Plot', values.hist(adjoin=False).opts(
            responsive=True, max_height=500, padding=0.1, color="#00aa41")),
        ('Summary', values.dframe().describe().T),
        ('Table', hv.Table(values)),

selections = pn.Column('### Distribution Type', checkboxes, slider)
pn.Row(selections, tabs)


Lets wrap it into nice template that can be served via panel serve distribution_tabs.ipynb

pn.template.FastListTemplate(site="Panel", title="Distribution Tabs", main=["This example demonstrates **how to plot several different types of outputs in a Tab**.", selections, tabs]).servable();
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).