File: C:/Users/fred/anaconda3/Lib/site-packages/holoviews/examples/reference/elements/bokeh/VSpan.ipynb
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: VSpan Element\n",
"\n",
"**Dependencies**: Bokeh\n",
"\n",
"**Backends**: [Matplotlib](../matplotlib/VSpan.ipynb), [Plotly](../plotly/VSpan.ipynb), [Bokeh](./VSpan.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('bokeh')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xs = np.linspace(-5, 5, 100)\n",
"ys = -(xs-2)**2\n",
"ymax = ys.argmax()\n",
"\n",
"curve = hv.Curve((xs,ys))\n",
"vspan = hv.VSpan(xs[ymax-5], xs[ymax+5])\n",
"\n",
"curve.opts(color='#D3D3D3') * vspan.opts(color='red')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"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`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"(hv.VSpan(1, 3) * hv.VSpan(5, 8)).opts(\n",
" opts.VSpan(apply_ranges=True))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.VSpan).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}