@@ -506,7 +506,7 @@ class Poly3DCollection(PolyCollection):
506
506
A collection of 3D polygons.
507
507
"""
508
508
509
- def __init__ (self , verts , * args , zsort = True , ** kwargs ):
509
+ def __init__ (self , verts , * args , zsort = 'average' , ** kwargs ):
510
510
"""
511
511
Create a Poly3DCollection.
512
512
@@ -534,26 +534,19 @@ def set_zsort(self, zsort):
534
534
535
535
Parameters
536
536
----------
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'.
541
541
"""
542
-
543
542
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." )
544
547
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 ]
555
549
self ._sort_zpos = None
556
- self ._zsortfunc = zsortfunc
557
550
self .stale = True
558
551
559
552
def get_vector (self , segments3d ):
@@ -633,15 +626,12 @@ def do_3d_projection(self, renderer):
633
626
else :
634
627
cedge = cedge .repeat (len (xyzlist ), axis = 0 )
635
628
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 )
645
635
646
636
segments_2d = [s for z , s , fc , ec , idx in z_segments_2d ]
647
637
if self ._codes3d is not None :
0 commit comments