Skip to content

Commit bd6f52a

Browse files
committed
Add comments to the example for clarity
1 parent eb687d8 commit bd6f52a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

examples/mplot3d/trisurf3d_demo2.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
from mpl_toolkits.mplot3d import Axes3D
44
import matplotlib.tri as mtri
55

6+
# u, v are parameterisation variables
67
u = (np.linspace(0, 2.0 * np.pi, endpoint=True, num=50) * np.ones((10, 1))).flatten()
78
v = np.repeat(np.linspace(-0.5, 0.5, endpoint=True, num=10), repeats=50).flatten()
89

10+
# This is the Mobius mapping, taking a u, v pair and returning an x, y, z
11+
# triple
912
x = (1 + 0.5 * v * np.cos(u / 2.0)) * np.cos(u)
1013
y = (1 + 0.5 * v * np.cos(u / 2.0)) * np.sin(u)
1114
z = 0.5 * v * np.sin(u / 2.0)
1215

16+
# Triangulate parameter space to determine the triangles
1317
tri = mtri.Triangulation(u, v)
1418

1519
fig = plt.figure()
1620
ax = fig.add_subplot(1, 1, 1, projection='3d')
21+
22+
# The triangles in parameter space determnine which x, y, z points are
23+
# connected by an edge
1724
ax.plot_trisurf(x, y, z, triangles=tri.triangles)
25+
1826
ax.set_zlim(-1, 1)
1927
plt.show()

0 commit comments

Comments
 (0)