@@ -49,7 +49,7 @@ class Axes3D(Axes):
49
49
def __init__ (
50
50
self , fig , rect = None , * args ,
51
51
azim = - 60 , elev = 30 , sharez = None , proj_type = 'persp' ,
52
- box_aspect = None ,
52
+ box_aspect = None , force_zorder = False ,
53
53
** kwargs ):
54
54
"""
55
55
Parameters
@@ -66,6 +66,10 @@ def __init__(
66
66
Other axes to share z-limits with.
67
67
proj_type : {'persp', 'ortho'}
68
68
The projection type, default 'persp'.
69
+ force_zorder : bool, optional
70
+ Force use of each collection and patch's zorder to determine
71
+ draw order. If this option is True, automatic draw order is
72
+ completely disabled. Defaults to False.
69
73
auto_add_to_figure : bool, default: True
70
74
Prior to Matplotlib 3.4 Axes3D would add themselves
71
75
to their host Figure on init. Other Axes class do not
@@ -84,6 +88,8 @@ def __init__(
84
88
-----
85
89
.. versionadded:: 1.2.1
86
90
The *sharez* parameter.
91
+ .. versionadded:: TBD
92
+ The *force_zorder* parameter.
87
93
"""
88
94
89
95
if rect is None :
@@ -92,6 +98,7 @@ def __init__(
92
98
self .initial_azim = azim
93
99
self .initial_elev = elev
94
100
self .set_proj_type (proj_type )
101
+ self .force_zorder = force_zorder
95
102
96
103
self .xy_viewLim = Bbox .unit ()
97
104
self .zz_viewLim = Bbox .unit ()
@@ -477,20 +484,26 @@ def do_3d_projection(artist):
477
484
"%(since)s and will be removed %(removal)s." )
478
485
return artist .do_3d_projection (renderer )
479
486
480
- # Calculate projection of collections and patches and zorder them.
481
- # Make sure they are drawn above the grids.
482
- zorder_offset = max (axis .get_zorder ()
483
- for axis in self ._get_axis_list ()) + 1
484
- for i , col in enumerate (
485
- sorted (self .collections ,
486
- key = do_3d_projection ,
487
- reverse = True )):
488
- col .zorder = zorder_offset + i
489
- for i , patch in enumerate (
490
- sorted (self .patches ,
491
- key = do_3d_projection ,
492
- reverse = True )):
493
- patch .zorder = zorder_offset + i
487
+ if self .force_zorder :
488
+ for col in self .collections :
489
+ col .do_3d_projection ()
490
+ for patch in self .patches :
491
+ patch .do_3d_projection ()
492
+ else :
493
+ # Calculate projection of collections and patches and zorder them.
494
+ # Make sure they are drawn above the grids.
495
+ zorder_offset = max (axis .get_zorder ()
496
+ for axis in self ._get_axis_list ()) + 1
497
+ for i , col in enumerate (
498
+ sorted (self .collections ,
499
+ key = do_3d_projection ,
500
+ reverse = True )):
501
+ col .zorder = zorder_offset + i
502
+ for i , patch in enumerate (
503
+ sorted (self .patches ,
504
+ key = do_3d_projection ,
505
+ reverse = True )):
506
+ patch .zorder = zorder_offset + i
494
507
495
508
if self ._axis3don :
496
509
# Draw panes first
0 commit comments