Skip to content

Commit 31c55ea

Browse files
authored
Merge pull request #12049 from anntzer/set_zsort
Make Poly3DCollection.set_zsort less lenient.
2 parents aae3af0 + 4696d88 commit 31c55ea

File tree

2 files changed

+21
-26
lines changed

2 files changed

+21
-26
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Poly3DCollection.set_zsort
2+
``````````````````````````
3+
4+
`Poly3DCollection.set_zsort` no longer silently ignores invalid inputs, or
5+
False (which was always broken). Passing True to mean "average" is deprecated.

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ class Poly3DCollection(PolyCollection):
506506
A collection of 3D polygons.
507507
"""
508508

509-
def __init__(self, verts, *args, zsort=True, **kwargs):
509+
def __init__(self, verts, *args, zsort='average', **kwargs):
510510
"""
511511
Create a Poly3DCollection.
512512
@@ -534,26 +534,19 @@ def set_zsort(self, zsort):
534534
535535
Parameters
536536
----------
537-
zsort : bool or {'average', 'min', 'max'}
538-
For 'average', 'min', 'max' the z-order is determined by applying
539-
the function to the z-coordinates of the vertices in the viewer's
540-
coordinate system. *True* is equivalent to 'average'.
537+
zsort : {'average', 'min', 'max'}
538+
The function applied on the z-coordinates of the vertices in the
539+
viewer's coordinate system, to determine the z-order. *True* is
540+
deprecated and equivalent to 'average'.
541541
"""
542-
543542
if zsort is True:
543+
cbook.warn_deprecated(
544+
"3.1", "Passing True to mean 'average' for set_zsort is "
545+
"deprecated and support will be removed in Matplotlib 3.3; "
546+
"pass 'average' instead.")
544547
zsort = 'average'
545-
546-
if zsort is not False:
547-
if zsort in self._zsort_functions:
548-
zsortfunc = self._zsort_functions[zsort]
549-
else:
550-
return False
551-
else:
552-
zsortfunc = None
553-
554-
self._zsort = zsort
548+
self._zsortfunc = self._zsort_functions[zsort]
555549
self._sort_zpos = None
556-
self._zsortfunc = zsortfunc
557550
self.stale = True
558551

559552
def get_vector(self, segments3d):
@@ -633,15 +626,12 @@ def do_3d_projection(self, renderer):
633626
else:
634627
cedge = cedge.repeat(len(xyzlist), axis=0)
635628

636-
# if required sort by depth (furthest drawn first)
637-
if self._zsort:
638-
z_segments_2d = sorted(
639-
((self._zsortfunc(zs), np.column_stack([xs, ys]), fc, ec, idx)
640-
for idx, ((xs, ys, zs), fc, ec)
641-
in enumerate(zip(xyzlist, cface, cedge))),
642-
key=lambda x: x[0], reverse=True)
643-
else:
644-
raise ValueError("whoops")
629+
# sort by depth (furthest drawn first)
630+
z_segments_2d = sorted(
631+
((self._zsortfunc(zs), np.column_stack([xs, ys]), fc, ec, idx)
632+
for idx, ((xs, ys, zs), fc, ec)
633+
in enumerate(zip(xyzlist, cface, cedge))),
634+
key=lambda x: x[0], reverse=True)
645635

646636
segments_2d = [s for z, s, fc, ec, idx in z_segments_2d]
647637
if self._codes3d is not None:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy