Distribution tabs

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

In [ ]:
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.

In [ ]:
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')
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)),
        ('Summary', values.dframe().describe().T),
        ('Table', hv.Table(values)),

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

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