HoloViews & hvPlot
HoloViews is a declarative plotting library from the HoloViz project: wrap data in typed elements (Curve, Scatter, Image, …) and compose them with * (overlay, shared axes) and + (layout, side by side), with no subplot bookkeeping. hvPlot puts a .hvplot accessor on a DataFrame that returns the same objects from one-line calls, and every example below uses it.

Tips vs. total bill, built from one .hvplot.scatter() call.
Installation
pip install 'shinywidgets[holoviews]'
This installs holoviews, panel, and jupyter_bokeh, which serves its widget JS locally so apps work offline. Add pip install hvplot yourself – every example below uses it. Without import hvplot.pandas (which registers the Bokeh extension as a side effect), call hv.extension("bokeh") once before using .opts(), or you’ll hit ValueError: No plotting extension is currently loaded.
Quick start
# A quick-start hvPlot scatter: one line of pandas turns into an interactive
# Bokeh plot (pan, zoom, hover) with no extra ceremony.
import plotly.express as px
import hvplot.pandas # noqa: F401 -- registers the .hvplot accessor on DataFrames
from shiny.express import ui
from shinywidgets import render_holoviews
tips = px.data.tips()
ui.page_opts(title="Tips, by total bill and tip", fillable=True)
@render_holoviews
def scatter():
return tips.hvplot.scatter(
"total_bill",
"tip",
by="day",
responsive=True,
title="Tips vs. total bill",
hover_cols=["size"],
)
Return any HoloViews or hvPlot object and @render_holoviews renders it. One .hvplot.scatter() call already produces pan, zoom, hover tooltips, and a clickable legend. responsive=True is the one thing to remember – without it the plot is a fixed 700x300px and won’t fill its card; see Layout and sizing.
Overview
A look at what you can build. Click any of them to open the app, with its code, in Shinylive.
A crossfiltered dashboard with click-for-detail
Crossfilter three charts, zero callbacks
Gapminder animation driven by a slider
Crossfilter selection drives two value boxes
Box-select on a scatter filters a table
Click a point for its detail card
In-place update keeps its zoom
Zoom range recomputes a live summary
Overlay and layout composition in one call
Minimal two-chart crossfilter template
Crossfilter views
hv.link_selections wraps any combination of plots and crossfilters them with no Python callback: box-select in one, and the others – plus the held-out points in the first – restyle to show what’s inside the selection.
# hv.link_selections crossfilters every plot it wraps: box-select in one chart
# and the others (plus any held-out, non-selected points) restyle to match --
# no Python callback written. A composite Layout like this defaults its drag
# tool to Pan, not Box Select, regardless of panel width -- set
# active_tools=["box_select"] on each element so box-select is the
# ready-to-use default instead.
import holoviews as hv
import plotly.express as px
import hvplot.pandas # noqa: F401
from shiny.express import ui
from shinywidgets import render_holoviews
hv.extension("bokeh")
tips = px.data.tips()
ui.page_opts(title="Crossfilter with link_selections", fillable=True)
# One instance per session (Express re-runs this module per session). A
# module-level instance would show every visitor's selection to everyone else.
links = hv.link_selections.instance(unselected_alpha=0.3)
@render_holoviews
def crossfilter():
scatter = tips.hvplot.scatter(
"total_bill", "tip", responsive=True, title="Bill vs. tip"
).opts(active_tools=["box_select"])
bill_hist = tips.hvplot.hist(
"total_bill", responsive=True, title="Bill distribution"
).opts(active_tools=["box_select"])
size_hist = tips.hvplot.hist("size", responsive=True, title="Party size").opts(
active_tools=["box_select"]
)
# Drag directly on any plot below to crossfilter the others -- box-select
# is already the active drag tool on every panel, no toolbar click needed.
return links(scatter + bill_hist + size_hist).opts(shared_axes=False)

Drag directly on any panel – active_tools=["box_select"] on each element makes box-select the default drag tool from the first render. Without it, a composite Layout wrapped in link_selections defaults to Pan instead, at any width. Build the link_selections instance inside the render function, or anywhere in a Shiny Express file (which already runs per session, as here) – a module-level instance in Shiny Core would show one visitor’s selection to everyone.
Elements compose the same way outside link_selections: * overlays plots on shared axes, + lays them out side by side, with no subplot bookkeeping – see the overlay-and-layout card in the Overview above.
Reacting to interaction
render_holoviews has no reactive accessors. HoloViews’ interaction model is its own streams (hv.streams.Tap, BoundsXY, Selection1D, RangeXY, …), which run their callbacks directly in Python. The recipe below bridges a stream into Shiny’s reactive graph: build the stream inside the render function (the same per-session reasoning as link_selections above applies here too, and streams only attach to a plot while it’s being built), subscribe with a lambda that calls .set() on a module-level reactive.Value, and read that value from any reactive function.
Box-select to filter a table
# The recipe for reacting to a HoloViews stream in Shiny: subscribe to it, and
# set a `reactive.Value` from the callback. The stream runs outside Shiny's
# render cycle, but setting a reactive value from it still invalidates
# whatever reads that value, same as any other reactive.Value.
import holoviews as hv
import plotly.express as px
import hvplot.pandas # noqa: F401
from shiny import reactive
from shiny.express import render, ui
from shinywidgets import render_holoviews
hv.extension("bokeh")
tips = px.data.tips()
ui.page_opts(title="Box-select to filter a table", fillable=True)
bounds_val = reactive.value(None)
@render_holoviews
def scatter():
points = tips.hvplot.scatter(
"total_bill", "tip", responsive=True, tools=["box_select"]
).opts(active_tools=["box_select"])
hv.streams.BoundsXY(source=points).add_subscriber(
lambda bounds: bounds_val.set(bounds)
)
return points
@render.data_frame
def selected_rows():
b = bounds_val()
if b is None:
return tips.iloc[:0] # empty frame until the first selection
x0, y0, x1, y1 = b
sel = tips[tips.total_bill.between(x0, x1) & tips.tip.between(y0, y1)]
return render.DataGrid(sel, height="250px")

A fresh render rebuilds the stream, so a new plot starts out with no selection – but the reactive.Value you set yourself keeps whatever it last held until the user interacts with the new plot. req(bounds_val()) works if you’d rather wait for the first interaction than handle None explicitly.
Click for details
# Click a point to show its full row in a detail card. hv.streams.Tap reports
# the data-space (x, y) of the click; the nearest row is looked up on the
# Shiny side, same recipe as the box-select example.
import holoviews as hv
import plotly.express as px
import hvplot.pandas # noqa: F401
from shiny import reactive
from shiny.express import render, ui
from shinywidgets import render_holoviews
hv.extension("bokeh")
tips = px.data.tips()
tap_xy = reactive.value(None)
ui.page_opts(title="Click a point for details", fillable=True)
with ui.layout_columns():
with ui.card(full_screen=True):
@render_holoviews
def scatter():
points = tips.hvplot.scatter(
"total_bill", "tip", responsive=True, tools=["tap"]
)
hv.streams.Tap(source=points).add_subscriber(
lambda x, y: tap_xy.set((x, y))
)
return points
with ui.card():
ui.card_header("Nearest table row")
@render.ui
def detail():
xy = tap_xy()
if xy is None:
return ui.p("Click a point in the plot.", class_="text-muted")
x, y = xy
dist = (tips.total_bill - x) ** 2 + (tips.tip - y) ** 2
row = tips.loc[dist.idxmin()]
return ui.TagList(
ui.h5(f"${row.total_bill:.2f} bill, ${row.tip:.2f} tip"),
ui.p(f"{row['size']} people, {row.day} {row.time}, smoker: {row.smoker}"),
)

hv.streams.Tap reports the clicked point in data coordinates; look up the nearest row on the Shiny side, the same recipe as the box-select example above.
Zoom range summary
# hv.streams.RangeXY reports the plot's current pan/zoom range -- store the
# range itself (not a counter) in the reactive.Value. RangeXY fires once on
# mount with the default range and again on every zoom/pan, including
# transiently during a drag; storing an ever-changing value like a counter
# caused a runaway re-render loop on older shinywidgets versions (fixed --
# see the guide's gotchas section) and is still wasted invalidation. Storing
# the actual range is idempotent: reactive.Value.set() skips invalidation
# when the new value equals the old one, so repeats of the same range are a
# no-op and only a genuine zoom/pan triggers a recompute.
import holoviews as hv
import plotly.express as px
import hvplot.pandas # noqa: F401
from shiny import reactive
from shiny.express import render, ui
from shinywidgets import render_holoviews
hv.extension("bokeh")
tips = px.data.tips()
ui.page_opts(title="Zoom range -> visible-point summary", fillable=True)
range_val = reactive.value((None, None))
@render_holoviews
def scatter():
points = tips.hvplot.scatter("total_bill", "tip", responsive=True)
hv.streams.RangeXY(source=points).add_subscriber(
lambda x_range, y_range: range_val.set((x_range, y_range))
)
return points
@reactive.calc
def visible():
x_range, y_range = range_val()
sub = tips
if x_range is not None:
sub = sub[sub.total_bill.between(*x_range)]
if y_range is not None:
sub = sub[sub.tip.between(*y_range)]
return sub
@render.text
def summary():
x_range, _ = range_val()
if x_range is None:
return f"{len(visible())} of {len(tips)} points visible (full range)"
lo, hi = x_range
return f"{len(visible())} of {len(tips)} points visible (total_bill {lo:.0f}-{hi:.0f})"

hv.streams.RangeXY reports the plot’s pan/zoom range, firing once on mount and again on every zoom or pan. Store the range itself, not a counter – reactive.Value.set() skips invalidating readers when the new value equals the old one, so once the range stops changing, the subscriber becomes a no-op.
Updating in place
Re-rendering (as in the Gapminder animation in the Overview above) is simplest, but it replaces the plot, so any zoom or pan the user made is lost. Driving a DynamicMap with a stream updates the existing plot instead – same Bokeh model, same comm, so the view survives.
# Driving a DynamicMap with a stream updates the existing plot: the bokeh
# model stays put, so pan/zoom state survives. Re-rendering (left as a
# contrast on the right) builds a brand-new plot every time, which resets
# the view. Click "New data" after zooming into both to see the difference.
import holoviews as hv
import numpy as np
from shiny import reactive
from shiny.express import input, render, ui
from shinywidgets import render_holoviews
hv.extension("bokeh")
rng = np.random.default_rng(0)
def random_walk(n=200):
return np.cumsum(rng.normal(size=n))
ui.page_opts(title="In-place update vs. re-render", fillable=True)
ui.input_action_button("refresh", "New data")
pipe = hv.streams.Pipe(data=random_walk())
with ui.layout_columns():
with ui.card(full_screen=True):
ui.card_header("In place: hv.streams.Pipe (preserves zoom)")
@render_holoviews
def in_place():
return hv.DynamicMap(
lambda data: hv.Curve(data).opts(responsive=True), streams=[pipe]
)
with ui.card(full_screen=True):
ui.card_header("Re-render: reads a reactive value directly (resets zoom)")
data = reactive.value(random_walk())
@render_holoviews
def rerendered():
return hv.Curve(data()).opts(responsive=True)
@reactive.effect
@reactive.event(input.refresh)
def _():
new_data = random_walk()
pipe.send(new_data)
data.set(new_data)

pipe.send(new_data) updates the left plot’s DynamicMap without rebuilding it, so its zoomed range survives; the right plot reads a reactive.Value directly and re-renders from scratch. stream.event(...) works the same way for a custom hv.streams.Stream subclass.
Linking widgets
link_selections’ crossfiltering is also a param event – watch it to bring the same selection into ordinary Shiny outputs: value boxes, tables, anything.
# link_selections crossfilters the plots on its own, but its selection is
# also a param event -- watch it to bring the same selection into ordinary
# Shiny outputs (here, two value boxes).
import holoviews as hv
import plotly.express as px
import hvplot.pandas # noqa: F401
from shiny import reactive
from shiny.express import render, ui
from shinywidgets import render_holoviews
hv.extension("bokeh")
tips = px.data.tips()
ui.page_opts(title="Crossfilter dashboard", fillable=True)
links = hv.link_selections.instance()
selection_expr = reactive.value(None)
_watcher = links.param.watch(
lambda event: selection_expr.set(event.new), "selection_expr"
)
@reactive.calc
def selected():
expr = selection_expr()
return tips if expr is None else links.filter(tips, selection_expr=expr)
with ui.layout_columns(fill=False):
with ui.value_box():
"Rows selected"
@render.text
def n_selected():
return f"{len(selected())} of {len(tips)}"
with ui.value_box():
"Average tip %"
@render.text
def avg_pct():
sel = selected()
if not len(sel):
return "-"
return f"{(sel.tip / sel.total_bill).mean():.1%}"
with ui.card(full_screen=True):
@render_holoviews
def crossfilter():
scatter = tips.hvplot.scatter(
"total_bill", "tip", responsive=True, title="Bill vs. tip"
).opts(active_tools=["box_select"])
tip_hist = tips.hvplot.hist(
"tip", responsive=True, title="Tip distribution"
).opts(active_tools=["box_select"])
return links(scatter + tip_hist).opts(shared_axes=False)

links.filter(df, selection_expr=expr) reproduces the selection as a pandas filter, so the same expr drives both the restyled plots (through link_selections itself) and any other Shiny output that needs the matching rows. The tips explorer in the Overview combines this with a day-of-week filter, a separate click-for-detail plot, and a data table, all driven by the same selection.
Large data
HoloViews’ own large-data mode is Datashader: hvPlot’s rasterize=True, or HoloViews’ rasterize() operation, bins millions of rows into a fixed-size image server-side through this same @render_holoviews decorator, so message size and render cost are set by screen resolution, not row count. This is the “summarize on the server” approach from Large data & performance. Without rasterize(), a plain element (a Scatter, a Points layer) has no scale story of its own beyond bokeh’s output_backend="webgl", which also applies here since HoloViews renders through Bokeh.
Layout and sizing
HoloViews and hvPlot elements are a fixed size by default – 300x300 for a bare HoloViews element, 700x300 for hvPlot – and get clipped by a smaller container rather than scaled down. Pass responsive=True (as an hvPlot kwarg, or .opts(responsive=True) for plain HoloViews) to make a plot fill its output instead:

An explicit height works as expected – @render_holoviews(height="300px") sizes a responsive plot to that height without needing fillable=True as well. full_screen=True on the enclosing ui.card() works the same as any other shinywidgets output.
Layouts (+) and overlays (*) made of responsive elements fill their container as a group; set .opts(shared_axes=False) if you don’t want HoloViews to link every subplot’s axes together.
Gotchas
- Each stream expects its subscriber’s parameters named a specific way (
BoundsXYneedsbounds,Tapneedsx, y,RangeXYneedsx_range, y_range). Get it wrong and the callback raises, but the only visible symptom is the box-select or click doing nothing in the browser – check the server log for the actual error. reactive_read()can’t read HoloViews streams orlink_selections. Use the stream-subscriber recipe above.rate_policy/rate_delayon@render_holoviewsdon’t throttle streams.TapandBoundsXYfire once per gesture; to throttle a stream that fires continuously, gate its subscriber yourself.
Learn more
- HoloViews documentation – element types, containers, streams, operations
- hvPlot documentation – the
.hvplotaccessor API - Linked Brushing /
link_selectionsuser guide - Custom Interactivity (streams) user guide
- bokeh – the lower-level library HoloViews renders through
- panel – for a general Panel app rather than plotting
- datashader – large-data rendering through the same decorator
- geoviews – geographic extensions to HoloViews