[英]Given general 3D plane equation, how can I plot this in python matplotlib?
Let's say I have a 3D plane equation: 假设我有一个3D平面方程:
ax+by+cz=d ax + by + cz = d
How can I plot this in python matplotlib? 如何在python matplotlib中绘制此图?
I saw some examples using plot_surface
, but it accepts x,y,z values as 2D array. 我看到了一些使用plot_surface
示例,但它接受x,y,z值作为2D数组。 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. 我不明白如何将方程式转换为对plot_surface
或matplotlib中可用plot_surface
任何其他函数的参数输入。
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.