给定一般的3D平面方程,我如何在python matplotlib中绘制这个?

时间:2018-01-19 06:25:13

标签: python matplotlib 3d

我们说我有一个3D平面方程式:

  

由+ CZ = d AX +

我如何在python matplotlib中绘制这个?

我看到了一些使用plot_surface的示例,但它接受x,y,z值作为2D数组。我不明白如何将我的方程式转换为plot_surface的参数输入或matplotlib中可用于此的任何其他函数。

1 个答案:

答案 0 :(得分:2)

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)