Skip to content

Instantly share code, notes, and snippets.

@skipperkongen
Created February 21, 2022 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skipperkongen/ddbfa2bad7594adad9251035094b94f6 to your computer and use it in GitHub Desktop.
Save skipperkongen/ddbfa2bad7594adad9251035094b94f6 to your computer and use it in GitHub Desktop.
3D plot with Pyplot
import matplotlib.pyplot as plt
import numpy as np
# https://jakevdp.github.io/PythonDataScienceHandbook/04.12-three-dimensional-plotting.html
def f(x, y):
return np.sin(np.sqrt(x ** 2 + y ** 2))
x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)
fig = plt.figure()
ax = plt.axes(projection='3d')
ax.contour3D(X, Y, Z, 50, cmap='binary')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment