1

I am trying to plot three planes in 3D space with Matplotlib.
What I got so far looks not good, and I want to ask.
Is there a better solution, so they are intersected?

x = np.linspace(-5,5,2)
y = np.linspace(-5,5,2)
z = np.linspace(-5,5,2)

X,Z = np.meshgrid(x,z)
Y1 = -2*X
Y2 = (-1+X+Z)/2
Y3 = -(4-4*z)/3

# plot the surface
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')


ax.plot_surface(X, Y1, Z, alpha=0.5)
ax.plot_surface(X, Y2, Z, alpha=0.5)
ax.plot_surface(X, Y3, Z, alpha=0.5)
plt.show()

my plot

Community
  • 1
  • 1
axolotl
  • 93
  • 6
  • The code is quite clean. Consider posting on https://codereview.stackexchange.com instead. Review questions are off topic for SO – Mad Physicist Apr 21 '20 at 06:32
  • But the Plot is kinda wrong, because you can see no depth. The Planes are drawn over each other in the wrong way. – axolotl Apr 21 '20 at 06:48
  • 1
    Thats a common problem with matplotlib, you can find a possible workaround here: [how-to-draw-intersecting-planes](https://stackoverflow.com/questions/14824893/how-to-draw-intersecting-planes/14825951#14825951) – TheIdealis Apr 21 '20 at 12:08
  • 1
    Perhaps you should edit the question? It's totally on-topic if there's an actual problem... – Mad Physicist Apr 21 '20 at 13:09
  • i did that and thanks for the answer! :) it seems really complicated though i hoped for a simple solution >_< also i do not have the angle needed in the example.. well probably thats just what matplotlib offers – axolotl Apr 21 '20 at 13:27
  • One thing that may help a little is changing the viewing angles using: `ax.view_init(80, 10)`. – BenT Apr 23 '20 at 21:48

0 Answers0