I’ve found a bug in mplot3d’s rendering of filled contours. Attached is a simple test script to reproduce the error and an example of the output: the 2D plot on the left shows the desired result, the 3D plot on the right shows the holes in the contour are not rendered correctly.
Digging around in axes3d.py and art3d.py, I think the problem is that mplot3d ignores the ‘codes’ that are produced by the 2D contourf routine. I am probably not using the correct terminology, but I understand that these codes allow a polygon to be composed of multiple line loops, some of which may be holes within other line loops. By ignoring the codes, the 3D routine renders a single polygon by concatenating all the points together regardless of whether they correspond to a hole or not.
In revision 8806 of lib/mpl_toolkits/mplot3d/art3d.py, lines 136-7:
for (((x, y), code), z) in zip(pathsegs, zs):
seg.append((x, y, z))
The codes are extracted from the pathsegs (which come from the 2D contourf routine), but then ignored.
I’ve taken a look at trying to fix this, but it was not obvious to me how to propagate the ‘codes’ rendering functionality from the 2D to 3D source code. Perhaps someone more familiar with mplot3d could look at it.
bug3d.py (333 Bytes)