Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,18 @@ def set_zsort(self, zsort):
self._sort_zpos = None
self.stale = True

def _zsortval(self, zs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _zsortval(self, zs):
def _zsortval(self, zs):
""" Compute the value to use for z-sorting given the viewer z coordinates of an object `zs`, with
larger values drawn underneath smaller values.
This function should never return `nan`, and returns `np.inf` if no non-nan value is computable.
"""

"""
Compute the value to use for z-sorting given the viewer z
coordinates of an object `zs`, with larger values drawn underneath
smaller values.

This function should never return `nan`, and returns `np.inf` if no
non-nan value is computable.
"""
nans = np.isnan(zs)
return np.inf if nans.all() else self._zsortfunc(zs[~nans])

def get_vector(self, segments3d):
"""Optimize points for projection."""
if len(segments3d):
Expand Down Expand Up @@ -815,7 +827,7 @@ def do_3d_projection(self, renderer=None):
if xyzlist:
# sort by depth (furthest drawn first)
z_segments_2d = sorted(
((self._zsortfunc(zs), np.column_stack([xs, ys]), fc, ec, idx)
((self._zsortval(zs), np.column_stack([xs, ys]), fc, ec, idx)
for idx, ((xs, ys, zs), fc, ec)
in enumerate(zip(xyzlist, cface, cedge))),
key=lambda x: x[0], reverse=True)
Expand Down