Vspan

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


Title: VSpan Element

Dependencies: Matplotlib

Backends: Bokeh, Plotly, Matplotlib

In [1]:
import numpy as np
import holoviews as hv
from holoviews import opts

hv.extension('matplotlib')

The VSpan element is a type of annotation that marks a range along the x-axis. Here is a VSpan marking maximum region of a quadratic curve:

In [2]:
xs = np.linspace(-5, 5, 100)
ys = -(xs-2)**2
ymax = ys.argmax()

curve = hv.Curve((xs,ys))
vspan = hv.VSpan(xs[ymax-5], xs[ymax+5])

curve.opts(color='#D3D3D3') * vspan.opts(facecolor='red')
Out[2]:

Like all annotation-like elements VSpan is not included in the calculation of axis ranges by default, but can be included by setting apply_ranges=True:

In [3]:
(hv.VSpan(1, 3) * hv.VSpan(5, 8)).opts(
    opts.VSpan(apply_ranges=True))
Out[3]:

For full documentation and the available style and plot options, use hv.help(hv.VSpan).


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