1
我是Matplotlib的新手,我需要在三維圖中繪製一個平面。我有等式中的a,b和c的值,例如1y + 2x + 3
。使用Matplotlib繪製3D曲面a * y + b * x + c
theta = np.array([1,2,3])
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(theta[0],theta[1],theta[2])
plt.show()
我知道這是不使用plot_surface()
功能以正確的方式,但我無法弄清楚如何。
更新1
我想出了使用線框的東西。
# Plot the plane
X = np.linspace(0,100, 500)
Y = np.linspace(0,100, 500)
Z = np.dot(theta[0],X) + np.dot(theta[1],Y) + theta[2]
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_wireframe(X,Y,Z)
plt.show()
但它只顯示一行。
你的函數只有一個變量,你怎麼能畫從一個3D圖形? –
我犯了一個錯誤,它會是y + 2x + 3 – Servietsky