Welcome to Panel!
This section will get you set up with Panel and provide a basic overview of the features and strengths of Panel. The announcement blog is another great resource to learn about the features of Panel and get an idea of what it can do.
conda install -c pyviz panel
or using PyPI:
pip install panel
Support for classic Jupyter Notebook is included with Panel. If you want to work with JupyterLab, you will also need to install the optional PyViz JupyterLab extension:
conda install -c conda-forge jupyterlab jupyter labextension install @pyviz/jupyterlab_pyviz
Panel lets you add interactive controls for just about anything you can display in Python. Panel can help you build simple interactive apps, complex multi-page dashboards, or anything in between. As a simple example, let's say you have created a function to plot a sine wave using Matplotlib and the Pandas
import numpy as np, pandas as pd, matplotlib.pyplot as plt %matplotlib inline def mplplot(df, **kwargs): fig = df.plot().get_figure() plt.close(fig) return fig def sine(frequency=1.0, amplitude=1.0, n=200, view_fn=mplplot): xs = np.arange(n)/n*20.0 ys = amplitude*np.sin(frequency*xs) df = pd.DataFrame(dict(y=ys), index=xs) return view_fn(df, frequency=frequency, amplitude=amplitude, n=n) sine(1.5, 2.5)
If we wanted to try out lots of combinations of these values to understand how frequency and amplitude affect this plot, we could reevaluate the above cell lots of times, but that would be a slow and painful process, and is only really appropriate for users who are comfortable with editing Python code.
Instead of editing code, it's much quicker and more straightforward to use sliders to adjust the values interactively. You can easily make a Panel app to explore a function's parameters using
pn.interact, which is similar to the ipywidgets interact function:
import panel as pn pn.extension() pn.interact(sine)