Hspan

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


Title: HSpan Element

Dependencies: Plotly

Backends: Bokeh, Matplotlib, Plotly

In [1]:
import numpy as np
import holoviews as hv
from holoviews import opts
hv.extension('plotly')

The HSpan element is a type of annotation that marks a range along the y-axis. Here is an HSpan element that marks the standard deviation in a collection of points:

In [2]:
xs = np.random.normal(size=500)
ys = np.random.normal(size=500) * xs
ymean, ystd = ys.mean(), ys.std()

points = hv.Points((xs,ys))
hspan  = hv.HSpan(ymean-ystd, ymean+ystd)

hspan.opts(fillcolor='blue') * points.opts(color='#D3D3D3')
Out[2]:

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

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

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


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