Path3d

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


Title
Path3D Element
Dependencies
Matplotlib
Backends
Matplotlib
Plotly
In [1]:
import numpy as np
import holoviews as hv

hv.extension('matplotlib')

A Path3D element represents one more lines, connecting arbitrary points in three-dimensional space. Path3D supports plotting an individual line or multiple subpaths, which should be supplied as a list. Each path should be defined in a columnar format such as NumPy arrays, DataFrames or dictionaries for each column. For a full description of the path geometry data model see the Geometry Data User Guide.

As a simple example we will genrate a random walk through 3D space as a single array with three columns:

In [2]:
line = np.random.randn(500, 3).cumsum(axis=0)
path = hv.Path3D(line)

path.opts(azimuth=40, elevation=20)
Out[2]:

Like the 2D equivalent Path also allows drawing multiple paths and allows coloring each by a value:

In [3]:
paths = [{('x', 'y', 'z'): np.random.randn(500, 3).cumsum(axis=0), 'index': i} for i in range(3)]
hv.Path3D(paths, vdims='index').opts(color='index', cmap=['red', 'green', 'blue'])
Out[3]:

Just like all regular 2D elements, Path3D types can be overlaid with other 2D and 3D elements:

In [4]:
scatter = hv.Scatter3D({('x', 'y', 'z'): line, 'index': np.arange(500)}, vdims='index')

path * scatter.opts(color='index', cmap='viridis', s=50)
Out[4]:

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


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