-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Incorrect drawing order when plotting polygons in separate Poly3DCollections #3894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
P.S.: I'm not sure if this is related to #3884, but at a glance it looks like a separate issue. |
This is a separate issue, and it is a fundamental limitation of what I call the 2.1D layering engine that matplotlib uses. The layering engine needs to sort the collections and independent artists according to a single z-order value (the ".1" of 2.1D layering). So, while some of the 3D collections are implemented to layer themselves properly (for the most part) by specially ordering the draws of their own elements on the fly (at a huge performance hit), they are completely unaware of any other artists and their spatial relationship to their own drawing elements. This leads to "Escher-esque" visual effects (they don't make spatial sense). A necessary, but not sufficient condition for this effect is that the 3D bounding boxes of artists intersect. There are some controls to help alleviate this. A collection object can either report a minimum, a maximum, or an average zsort value for itself. It defaults to minimum. This is why removing the one triangle "fixed" it. This is a known limitation, and addressed in the documentation. Don't use mplot3d for complex scenes. There are better tools for that such as mayavi. So, I will close this issue. |
Thanks for the quick reply and the detailed explanation! The example I posted is actually a very stripped down version of a larger example where I plotted various "layers" (which are all parallel to the x-y plane) using triangulations. Since these layers can be trivially ordered using their z-coordinate, I thought that matplotlib would be able to automatically pick this up and display it correctly. Unfortunately, as you pointed out, it doesn't seem to be so easy. But I just tried to give it a "nudge" by calling Out of interest, would it be feasible to have a flag which forces each artist to take all the other artists into account when computing the 3D layering of a scene? I appreciate that this might be very slow, but I can imagine situations where a user would be willing to sacrifice speed if the resulting plot looks correct. |
I once considered something like that (or some sort of flattening operation But if the individual artist elements are well-behaved, then it might be On Sat, Dec 6, 2014 at 1:21 PM, maxalbert notifications@github.com wrote:
|
There is a bug when using multiple
Poly3DCollection
s which can result in incorrect drawing order so that a polygon that should be on top of another one is actually displayed underneath. The script below shows a minimal example.The example script creates two figure windows. In the first one three triangles are drawn using a single
Poly3DCollection
. This works as expected. In the second one the triangles are drawn using two separatePoly3DCollection
s. In this case the green triangle (from the second collection) is displayed underneath the red one (from the first collection) even though it should be on top of it. Interestingly, the bug disappears if the blue triangle (which does not overlap with the green one) is removed from the first collection.The text was updated successfully, but these errors were encountered: