@@ -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