5.4.17 · D3Scientific Computing (Python)

Worked examples — 3D plots — surface, wireframe

2,087 words9 min readBack to topic

Everything below builds only on the parent note and these prerequisites: the parent topic, NumPy vectorization, Matplotlib figure and axes objects, Colormaps in Matplotlib, and Contour plots.


The scenario matrix

Before any code, here is the full space of cases a 3D-surface problem can throw at you. Each later example is tagged with the cell it covers.

# Case class What's special Example
A Positive bowl (normal case) everywhere, smooth Ex 1
B Negative / saddle heights takes both signs — sign matters Ex 2
C Zero / degenerate input — flat function constant, surface is a plane Ex 3
D Single-point / empty grid len(x)=1 or len=0 — edge inputs Ex 4
E Shape / transpose bug Z.shape vs (len(y),len(x)) Ex 5
F Limiting behaviour — ripple far out , crest radii Ex 6
G Real-world word problem terrain / height reading Ex 7
H Exam twist — wireframe stride count how many lines actually drawn Ex 8

We hit every cell A–H below.


Example 1 — Cell A: the positive bowl


Example 2 — Cell B: negative and saddle heights


Example 3 — Cell C: degenerate flat function


Example 4 — Cell D: single-point and empty grids


Example 5 — Cell E: the transpose bug


Example 6 — Cell F: limiting behaviour, the ripple


Example 7 — Cell G: real-world word problem


Example 8 — Cell H: exam twist — counting wireframe lines


Active Recall

Recall Min of

Z = X**2 + Y**2? at the origin — sum of two squares can't go below zero.

Recall Is

X**2 - Y**2 a bowl or a saddle? A saddle: up along , down along ; takes both signs.

Recall

meshgrid shape for len(x)=1, len(y)=3? (3, 1) — too thin to draw a real surface patch.

Recall First crest radius of

sin(sqrt(X**2+Y**2))? , where .

Recall Lines drawn by

rstride=10 on a 61-row grid? .

Prediction line — cover the answer:

Summit of and its height?
at , height m.

Connections

  • 3D plots — surface, wireframe (parent)
  • meshgrid and broadcasting
  • NumPy vectorization
  • Matplotlib figure and axes objects
  • Colormaps in Matplotlib
  • Contour plots