Given general 3D plane equation, how can I plot th

2019-07-13 10:59发布

Let's say I have a 3D plane equation:

ax+by+cz=d

How can I plot this in python matplotlib?

I saw some examples using plot_surface, but it accepts x,y,z values as 2D array. I don't understand how can I convert my equation into the parameter inputs to plot_surface or any other functions in matplotlib that can be used for this.

1条回答
可以哭但决不认输i
2楼-- · 2019-07-13 11:31
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

a,b,c,d = 1,2,3,4

x = np.linspace(-1,1,10)
y = np.linspace(-1,1,10)

X,Y = np.meshgrid(x,y)
Z = (d - a*X - b*Y) / c

fig = plt.figure()
ax = fig.gca(projection='3d')

surf = ax.plot_surface(X, Y, Z)
查看更多
登录 后发表回答