Created
February 21, 2022 19:23
-
-
Save skipperkongen/ddbfa2bad7594adad9251035094b94f6 to your computer and use it in GitHub Desktop.
3D plot with Pyplot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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