Skip to content

Commit

Permalink
Vectorized VLines, HLines, VSpans and HSpans elements (#5845)
Browse files Browse the repository at this point in the history
Co-authored-by: Simon Høxbro Hansen <[email protected]>
Co-authored-by: Philipp Rudiger <[email protected]>
  • Loading branch information
3 people authored Sep 18, 2023
1 parent 0dad517 commit 06d2b6d
Show file tree
Hide file tree
Showing 16 changed files with 1,311 additions and 6 deletions.
11 changes: 11 additions & 0 deletions examples/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import platform
import sys

import bokeh
import pandas as pd
from packaging.version import Version

Expand Down Expand Up @@ -40,6 +41,16 @@
]


# First available in Bokeh 3.2.0
if Version(bokeh.__version__) < Version("3.2.0"):
collect_ignore_glob += [
"reference/elements/bokeh/HLines.ipynb",
"reference/elements/bokeh/HSpans.ipynb",
"reference/elements/bokeh/VLines.ipynb",
"reference/elements/bokeh/VSpans.ipynb",
]


def pytest_runtest_makereport(item, call):
"""
Skip tests that fail because "the kernel died before replying to kernel_info"
Expand Down
59 changes: 59 additions & 0 deletions examples/reference/elements/bokeh/HLines.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: HLine Element\n",
"\n",
"**Dependencies**: Bokeh 3.2\n",
"\n",
"**Backends**: [Matplotlib](../matplotlib/HLines.ipynb), [Bokeh](../bokeh/HLines.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"\n",
"hv.extension('bokeh')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``HLines`` element is a type of annotation that can mark multiple lines along the y-axis. It accepts a list of y-coordinates and will draw a horizontal line at each location. This has the advantage over [``HLine``](./HLine.ipynb) of being able to draw multiple lines at once and also being able to get hover information for each of the line."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ys = np.random.normal(size=10)\n",
"hv.HLines(ys).opts(tools=['hover'], color='red', line_width=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.HLines).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
60 changes: 60 additions & 0 deletions examples/reference/elements/bokeh/HSpans.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: HLine Element\n",
"\n",
"**Dependencies**: Bokeh 3.2\n",
"\n",
"**Backends**: [Matplotlib](../matplotlib/HSpans.ipynb), [Bokeh](../bokeh/HSpans.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"\n",
"hv.extension('bokeh')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``HSpans`` element is a type of annotation that can mark multiple spans along the y-axis. It accepts a list of start and end y-coordinates and will draw horizontal spans. This has the advantage over [``HSpan``](./HSpan.ipynb) of being able to draw multiple spans at once and also being able to get hover information for each of the span."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"y_start = np.arange(10)\n",
"y_end = y_start + np.random.random(size=10) / 2\n",
"hv.HSpans((y_start, y_end)).opts(tools=['hover'], color='red')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.HSpans).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
59 changes: 59 additions & 0 deletions examples/reference/elements/bokeh/VLines.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: HLine Element\n",
"\n",
"**Dependencies**: Bokeh 3.2\n",
"\n",
"**Backends**: [Matplotlib](../matplotlib/VLines.ipynb), [Bokeh](../bokeh/VLines.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"\n",
"hv.extension('bokeh')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``VLines`` element is a type of annotation that can mark multiple lines along the x-axis. It accepts a list of x-coordinates and will draw a vertical line at each location. This has the advantage over [``VLine``](./VLine.ipynb) of being able to draw multiple lines at once and also being able to get hover information for each of the line."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"xs = np.random.normal(size=10)\n",
"hv.VLines(xs).opts(tools=['hover'], color='red', line_width=5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.VLines).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
60 changes: 60 additions & 0 deletions examples/reference/elements/bokeh/VSpans.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: HLine Element\n",
"\n",
"**Dependencies**: Bokeh 3.2\n",
"\n",
"**Backends**: [Matplotlib](../matplotlib/VSpans.ipynb), [Bokeh](../bokeh/VSpans.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"\n",
"hv.extension('bokeh')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``VSpans`` element is a type of annotation that can mark multiple spans along the x-axis. It accepts a list of start and end x-coordinates and will draw vertical spans at each location. This has the advantage over [``VSpan``](./VSpan.ipynb) of being able to draw multiple spans at once and also being able to get hover information for each of the span."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"x_start = np.arange(10)\n",
"x_end = x_start + np.random.random(size=10) / 2\n",
"hv.VSpans((x_start, x_end)).opts(tools=['hover'], color='red')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.VSpans).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
59 changes: 59 additions & 0 deletions examples/reference/elements/matplotlib/HLines.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: HLine Element\n",
"\n",
"**Dependencies**: Matplotlib\n",
"\n",
"**Backends**: [Matplotlib](../matplotlib/HLines.ipynb), [Bokeh](../bokeh/HLines.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"\n",
"hv.extension('matplotlib')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``HLines`` element is a type of annotation that can mark multiple lines along the y-axis. It accepts a list of y-coordinates and will draw a horizontal line at each location. This has the advantage over [``HLine``](./HLine.ipynb) of being able to draw multiple lines at once."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ys = np.random.normal(size=10)\n",
"hv.HLines(ys).opts(color='red')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.HLines).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
60 changes: 60 additions & 0 deletions examples/reference/elements/matplotlib/HSpans.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### **Title**: HLine Element\n",
"\n",
"**Dependencies**: Matplotlib\n",
"\n",
"**Backends**: [Matplotlib](../matplotlib/HSpans.ipynb), [Bokeh](../bokeh/HSpans.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import holoviews as hv\n",
"\n",
"hv.extension('matplotlib')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``HSpans`` element is a type of annotation that can mark multiple spans along the y-axis. It accepts a list of start and end y-coordinates and will draw horizontal spans. This has the advantage over [``HSpan``](./HSpan.ipynb) of being able to draw multiple spans at once."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"y_start = np.arange(10)\n",
"y_end = y_start + np.random.random(size=10) / 2\n",
"hv.HSpans((y_start, y_end)).opts(color='red')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For full documentation and the available style and plot options, use ``hv.help(hv.HSpans).``"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 06d2b6d

Please sign in to comment.