@@ -933,30 +933,32 @@ def can_pan(self):
933933 """
934934 return False
935935
936+ def sharez (self , other ):
937+ """
938+ Share the z-axis with *other*.
939+
940+ This is equivalent to passing ``sharex=other`` when constructing the
941+ Axes, and cannot be used if the z-axis is already being shared with
942+ another Axes.
943+ """
944+ _api .check_isinstance (maxes ._base ._AxesBase , other = other )
945+ if self ._sharez is not None and other is not self ._sharez :
946+ raise ValueError ("z-axis is already shared" )
947+ self ._shared_axes ["z" ].join (self , other )
948+ self ._sharez = other
949+ self .zaxis .major = other .zaxis .major # Ticker instances holding
950+ self .zaxis .minor = other .zaxis .minor # locator and formatter.
951+ z0 , z1 = other .get_zlim ()
952+ self .set_zlim (z0 , z1 , emit = False , auto = other .get_autoscalez_on ())
953+ self .zaxis ._scale = other .zaxis ._scale
954+
936955 def clear (self ):
937956 # docstring inherited.
938957 super ().clear ()
939- self .zaxis .clear ()
940-
941- if self ._sharez is not None :
942- self .zaxis .major = self ._sharez .zaxis .major
943- self .zaxis .minor = self ._sharez .zaxis .minor
944- z0 , z1 = self ._sharez .get_zlim ()
945- self .set_zlim (z0 , z1 , emit = False , auto = None )
946- self .zaxis ._set_scale (self ._sharez .zaxis .get_scale ())
947- else :
948- self .zaxis ._set_scale ('linear' )
949- try :
950- self .set_zlim (0 , 1 )
951- except TypeError :
952- pass
953-
954- self .set_autoscalez_on (True )
955958 if self ._focal_length == np .inf :
956959 self ._zmargin = rcParams ['axes.zmargin' ]
957960 else :
958961 self ._zmargin = 0.
959-
960962 self .grid (rcParams ['axes3d.grid' ])
961963
962964 def _button_press (self , event ):
0 commit comments