9

I know that matplotlib 3D is not reliable for plotting multiple 3D objects (planes, lines, points) in the right order: please see Matplotlib 3D plot zorder issue and How to draw intersecting planes?. However these questions seem quite old, so the proposed solutions. Thus, I would like to know if there are some new developments, tools, workarounds or hard-coded solutions for the following specific simple scenario:

import mpl_toolkits.mplot3d as a3
import matplotlib.pylab as plt
import numpy as np    

fig = plt.figure()
ax = a3.Axes3D(fig)

# create an orizontal plane
corners = [[0,0,0],[0,5,0],[5,5,0],[5,0,0]]
tri = a3.art3d.Poly3DCollection([corners], alpha=1)
tri.set_color('w')
tri.set_edgecolor('k')
ax.add_collection3d(tri)

# plot a vector
ax.plot([2,2],[2,2],[0,4], c = 'r')

# plot some points
ax.scatter([1,3],[1,3],[1,3], c = 'r')

ax.set_xlim([0, 5.0])
ax.set_ylim([0, 5.0])
ax.set_zlim([0, 2.5]);

plt.show()

In this image you can see the visualization issues: the vector it is not starting from the plane, as it should since his intiali point is (2,2,0)

In this image you can see the visualization issues: the vector it is not starting from the plane, as it should since his intiali point is (2,2,0)

8
  • Your code produces the correct result for me. The red line starts at [2, 2, 0] as expected, and is not clipped. Matplotlib 2.1.1 and QT5Agg backend. Maybe your backend is at fault? Oct 22, 2018 at 7:42
  • Works for me here too, red line starts at [2, 2, 0] as expected. matplotlib2.2.3, Qt5Agg backend
    – SpghttCd
    Oct 22, 2018 at 9:39
  • Thank you for the answer, but unfortunately it does not solve the issue. I tried also with both 'Qt5Agg' and 'WxAgg'
    – Chutlhu
    Oct 22, 2018 at 10:07
  • I'm sorry to read that - and the matplotlib version is also recent enough?
    – SpghttCd
    Oct 22, 2018 at 10:26
  • 2
    Thank you so much. Here it is github.com/matplotlib/matplotlib/issues/12620
    – Chutlhu
    Oct 24, 2018 at 18:21

0

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.