{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "
\n", "
Title
Path3D Element
\n", "
Dependencies
Matplotlib
\n", "
Backends
\n", "
Matplotlib
\n", "
Plotly
\n", "
\n", "
" ] }, { "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": [ "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](../user_guide/Geometry_Data.ipynb).\n", "\n", "As a simple example we will generate a random walk through 3D space as a single array with three columns:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "line = np.random.randn(500, 3).cumsum(axis=0)\n", "path = hv.Path3D(line)\n", "\n", "path.opts(azimuth=40, elevation=20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Like the 2D equivalent ``Path`` also allows drawing multiple paths and allows coloring each by a value:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "paths = [{('x', 'y', 'z'): np.random.randn(500, 3).cumsum(axis=0), 'index': i} for i in range(3)]\n", "hv.Path3D(paths, vdims='index').opts(color='index', cmap=['red', 'green', 'blue'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Just like all regular 2D elements, ``Path3D`` types can be overlaid with other 2D and 3D elements:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "scatter = hv.Scatter3D({('x', 'y', 'z'): line, 'index': np.arange(500)}, vdims='index')\n", "\n", "path * scatter.opts(color='index', cmap='viridis', s=50)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For full documentation and the available style and plot options, use ``hv.help(hv.Path3D).``" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 2 }