Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#iterate x and y so that z can be obtained
X,Y = np.meshgrid(np.arange(-2, 3),np.arange(-2, 3))
Z = np.zeros(X.shape)
norm_vector = np.array([0.22,0.44,0.65]) # arbitrary normal vector (but z can't be zero)
#norm_vec [A,B,C] representing plane Ax+By+Cz = 1
for r in range(X.shape[0]):
for c in range(X.shape[1]):
Z[r,c] = (1- (norm_vector[0] * X[r,c]+ norm_vector[1] * Y[r,c]))/ norm_vector[2]
ax.plot_wireframe(X,Y,Z, color='k')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment