I want to plot multiple 3D planes using plot_surface function of matplotlib. I am using this link as reference.
I have planes that lie completely in ZY, ZX plane. In the link's solution I found that shifting the normal would work. It does not work with my code:
for k in np.arange(len(t)):
d[k] = -(np.dot(point[k], normal[k].T))
xx, yy = np.meshgrid(np.arange(np.amin(t[..., 0]),
np.amax(t[..., 0] + 1)),
np.arange(np.amin(t[..., 1]), np.amax(t[..., 1] + 1)))
if (normal[k][2] == 0) and (normal[k][0] == 0):
z = (-normal[k][2] * xx - normal[k][0] * yy - d[k]) * 1. / normal[k][1]
elif (normal[k][2] == 0) and (normal[k][1] == 0):
z = (-normal[k][1] * xx - normal[k][2] * yy - d[k]) * 1. / normal[k][0]
else:
z = (-normal[k][0] * xx - normal[k][1] * yy - d[k]) * 1. / normal[k][2]
ax.plot_surface(xx, yy, z, color="black", linewidth=0, alpha=0.5)
xx and yy are a meshgrid of the range I want and k is just the index I am using to loop over all the planes.
Is my code correct? If not, what should be changed for it to work? Is there a better way to achieve this?
Edit: The expected output is a cube from all the planes instead I am only getting the planes in XY coordinate plane.
Is my code correct?I don't understand this question. Do you get the expected output or not? Why do you have to ask us?