You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: mplot3d is useful, but is limited by the z-ordering rendering engine of matplotlib. It is incapable of properly constructing a scene with multiple elements that have overlapping bounding boxes. There are some tricks to help mitigate this somewhat, but it can never truely be solved.
Oy, seriously? I don't see any unit tests in that PR, and I don't think anybody asked for my review of the mplot3d portions. I would have pointed out that the fundamental design of mplot3d prevents having an axis above anything.
Looking at it again I am tempted to close this as "not worse than the known issues with mplot3d".
In 2.2, things would "work" if you had only two PolyCollections, but not three:
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)
corners = [[0,0,1],[0,5,1],[5,5,1],[5,0,1]]
tri = a3.art3d.Poly3DCollection([corners], alpha=1)
tri.set_color('w')
tri.set_edgecolor('k')
ax.add_collection3d(tri)
corners = [[0,0,2],[0,5,2],[5,5,2],[5,0,2]]
tri = a3.art3d.Poly3DCollection([corners], alpha=1)
tri.set_color('w')
tri.set_edgecolor('k')
ax.add_collection3d(tri)
# plot a vector
ax.plot([0,0],[5,5],[-10,10], 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()
because the PolyCollections would get assigned increasing zorders -- 0, 1, 2 and thus at some point crosses the (default) zorder of Line2D's (which is 2). The change in #9094 is that the numbering of PolyCollection zorders now start higher (2.5) and is now above the default Line2D zorder from the beginning.
The solution in either case is to set the zorder of the line to a high enough value, e.g. ax.plot(..., zorder=10) works in all cases.
Based on the above solution, I'm closing. Agree this is suboptimal, and indeed may have changed in 3.0.0, but I don't think we should bother fixing it given the limitations on draw order in mplot3d.
Activity
WeatherGod commentedon Oct 24, 2018
https://matplotlib.org/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles
TL;DR: mplot3d is useful, but is limited by the z-ordering rendering engine of matplotlib. It is incapable of properly constructing a scene with multiple elements that have overlapping bounding boxes. There are some tricks to help mitigate this somewhat, but it can never truely be solved.
ImportanceOfBeingErnest commentedon Oct 24, 2018
Thanks.
The main point being that this is a regression to 2.2.3. Bisects to #9094
WeatherGod commentedon Oct 24, 2018
Oy, seriously? I don't see any unit tests in that PR, and I don't think anybody asked for my review of the mplot3d portions. I would have pointed out that the fundamental design of mplot3d prevents having an axis above anything.
tacaswell commentedon Oct 25, 2018
Pushed out as I don't think this is going to be fixed in the next 6-12 hours.
tacaswell commentedon Oct 25, 2018
Sorry @WeatherGod This looks like my mistake to merge 🐑
anntzer commentedon Oct 29, 2018
Looking at it again I am tempted to close this as "not worse than the known issues with mplot3d".
In 2.2, things would "work" if you had only two PolyCollections, but not three:
because the PolyCollections would get assigned increasing zorders -- 0, 1, 2 and thus at some point crosses the (default) zorder of Line2D's (which is 2). The change in #9094 is that the numbering of PolyCollection zorders now start higher (2.5) and is now above the default Line2D zorder from the beginning.
The solution in either case is to set the zorder of the line to a high enough value, e.g.
ax.plot(..., zorder=10)works in all cases.jklymak commentedon Oct 31, 2018
Based on the above solution, I'm closing. Agree this is suboptimal, and indeed may have changed in 3.0.0, but I don't think we should bother fixing it given the limitations on draw order in mplot3d.