File: C:/Users/fred/anaconda3/Lib/site-packages/holoviews/examples/reference/elements/plotly/HSpan.ipynb
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: HSpan Element\n",
"\n",
"**Dependencies**: Plotly\n",
"\n",
"**Backends**: [Bokeh](../bokeh/HSpan.ipynb), [Matplotlib](../matplotlib/HSpan.ipynb), [Plotly](./HSpan.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"from holoviews import opts\n",
"hv.extension('plotly')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xs = np.random.normal(size=500)\n",
"ys = np.random.normal(size=500) * xs\n",
"ymean, ystd = ys.mean(), ys.std()\n",
"\n",
"points = hv.Points((xs,ys))\n",
"hspan = hv.HSpan(ymean-ystd, ymean+ystd)\n",
"\n",
"hspan.opts(fillcolor='blue') * points.opts(color='#D3D3D3')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"(hv.HSpan(1, 3) * hv.HSpan(5, 8)).opts(\n",
" opts.HSpan(apply_ranges=True))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.HSpan).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}