Code
from matplotlib import pylab as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator
import numpy as np
; plt.ion()
ION MagNav Workshop, PLANS 2023, Monterey, CA
Aaron Nielsen
The views expressed in this article are those of the author and do not necessarily reflect the official policy or position of the United States Government, Department of Defense, United States Air Force or Air University.
Distribution A: Authorized for public release. Distribution is unlimited. Case No. 2023-0427.
Imagine a surface that is actually periodic in all directions:
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
# Make data.
X = np.arange(-2*np.pi, 2*np.pi, 0.1)
Y = np.arange(-2*np.pi, 2*np.pi, 0.1)
X, Y = np.meshgrid(X, Y)
Z = np.sin(X) * np.sin(Y)
# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.cubehelix,
linewidth=0, antialiased=False)
# Customize the z axis.
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
# A StrMethodFormatter is used automatically
ax.zaxis.set_major_formatter('{x:.02f}')
# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)
plt.show()
modified from https://matplotlib.org/stable/gallery/mplot3d/surface3d.html