HoloViews#

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


import panel as pn
pn.extension('plotly')

The HoloViews pane renders HoloViews plots with one of the plotting backends supported by HoloViews. It supports the regular HoloViews widgets for exploring the key dimensions of a HoloMap or DynamicMap, but is more flexible than the native HoloViews widgets since it also allows customizing widget types and their position relative to the plot.

Parameters:#

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

  • backend (str): Any of the supported HoloViews backends (‘bokeh’, ‘matplotlib’, or ‘plotly’)

  • center (boolean, default=False): Whether to center the plot

  • linked_axes (boolean, default=True): Whether to link axes across plots in a panel layout

  • object (object): The HoloViews object being displayed

  • widget_location (str): Where to lay out the widget relative to the plot

  • widget_layout (ListPanel type): The object to lay the widgets out in, one of Row, Column or WidgetBox

  • widget_type (str): Whether to generate individual widgets for each dimension, or to use a global linear scrubber with dimensions concatenated.

  • widgets (dict): A mapping from dimension name to a widget class, instance, or dictionary of overrides to modify the default widgets.

Display#

  • default_layout (pn.layout.Panel, default=Row): Layout to wrap the plot and widgets in


The panel function will automatically convert any HoloViews object into a displayable panel, while keeping all of its interactive features:

import numpy as np
import holoviews as hv

box = hv.BoxWhisker((np.random.randint(0, 10, 100), np.random.randn(100)), 'Group').sort()

hv_layout = pn.panel(box)
hv_layout

By setting the pane’s object the plot can be updated like all other pane objects:

hv_layout.object = hv.Violin(box).opts(violin_color='Group', cmap='Category20')

Widgets#

HoloViews natively renders plots with widgets if a HoloMap or DynamicMap declares any key dimensions. Unlike Panel’s interact functionality, this approach efficiently updates just the data inside a plot instead of replacing it entirely. Calling pn.panel on the DynamicMap will return a Row layout (configurable via the default_layout option), which is equivalent to calling pn.pane.HoloViews(dmap).layout:

import pandas as pd
import hvplot.pandas
import holoviews.plotting.bokeh

def sine(frequency=1.0, amplitude=1.0, function='sin'):
    xs = np.arange(200)/200*20.0
    ys = amplitude*getattr(np, function)(frequency*xs)
    return pd.DataFrame(dict(y=ys), index=xs).hvplot()

dmap = hv.DynamicMap(sine, kdims=['frequency', 'amplitude', 'function']).redim.range(
    frequency=(0.1, 10), amplitude=(1, 10)).redim.values(function=['sin', 'cos', 'tan'])

hv_panel = pn.panel(dmap)

hv_panel.pprint()