{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import panel as pn\n",
    "import numpy as np\n",
    "import holoviews as hv\n",
    "\n",
    "pn.extension()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "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."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "distributions = {\n",
    "    'normal': np.random.normal,\n",
    "    'uniform': np.random.uniform,\n",
    "    'log-normal': np.random.lognormal,\n",
    "    'exponential': np.random.exponential\n",
    "}\n",
    "\n",
    "checkboxes = pn.widgets.ToggleGroup(options=distributions, behavior='radio')\n",
    "slider = pn.widgets.IntSlider(name='Number of observations', value=500, start=0, end=2000)\n",
    "\n",
    "@pn.depends(checkboxes.param.value, slider.param.value)\n",
    "def tabs(distribution, n):\n",
    "    values = hv.Dataset(distribution(size=n), 'values')\n",
    "    return pn.Tabs(\n",
    "        ('Plot', values.hist(adjoin=False).opts(\n",
    "            responsive=True, max_height=500, padding=0.1)),\n",
    "        ('Summary', values.dframe().describe().T),\n",
    "        ('Table', hv.Table(values)),\n",
    "    )\n",
    "\n",
    "pn.Row(pn.Column('### Distribution Type', checkboxes, slider), tabs).servable()"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
