Trisurf3d Demo#

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


URL: http://matplotlib.org/examples/mplot3d/trisurf3d_demo.html

Most examples work across multiple plotting backends, this example is also available for:

HoloViews#

import numpy as np
import holoviews as hv
hv.extension('matplotlib')

Define data#

n_radii = 8
n_angles = 36

# Make radii and angles spaces (radius r=0 omitted to eliminate duplication).
radii = np.linspace(0.125, 1.0, n_radii)
angles = np.linspace(0, 2*np.pi, n_angles, endpoint=False)

# Repeat all angles for each radius.
angles = np.repeat(angles[..., np.newaxis], n_radii, axis=1)

# Convert polar (radii, angles) coords to cartesian (x, y) coords.
# (0, 0) is manually added at this stage,  so there will be no duplicate
# points in the (x, y) plane.
x = np.append(0, (radii*np.cos(angles)).flatten())
y = np.append(0, (radii*np.sin(angles)).flatten())

# Compute z to make the pringle surface.
z = np.sin(-x*y)

trisurface = hv.TriSurface((x, y, z))

Plot#

trisurface.opts(fig_size=200)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

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