Trisurf3d demo

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

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

HoloViews

In [1]:
import numpy as np
import holoviews as hv
hv.extension('matplotlib')
%output backend='matplotlib' size=200

Define data

In [2]:
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

In [3]:
trisurface
Out[3]:

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