@@ -52,6 +52,8 @@ class Axes3D(Axes):
5252 _axis_names = ("x" , "y" , "z" )
5353 Axes ._shared_axes ["z" ] = cbook .Grouper ()
5454
55+ dist = _api .deprecate_privatize_attribute ("3.6" )
56+
5557 def __init__ (
5658 self , fig , rect = None , * args ,
5759 elev = 30 , azim = - 60 , roll = 0 , sharez = None , proj_type = 'persp' ,
@@ -197,10 +199,10 @@ def convert_zunits(self, z):
197199 def set_top_view (self ):
198200 # this happens to be the right view for the viewing coordinates
199201 # moved up and to the left slightly to fit labels and axes
200- xdwl = 0.95 / self .dist
201- xdw = 0.9 / self .dist
202- ydwl = 0.95 / self .dist
203- ydw = 0.9 / self .dist
202+ xdwl = 0.95 / self ._dist
203+ xdw = 0.9 / self ._dist
204+ ydwl = 0.95 / self ._dist
205+ ydw = 0.9 / self ._dist
204206 # This is purposely using the 2D Axes's set_xlim and set_ylim,
205207 # because we are trying to place our viewing pane.
206208 super ().set_xlim (- xdwl , xdw , auto = None )
@@ -348,12 +350,14 @@ def set_box_aspect(self, aspect, *, zoom=1):
348350 aspect : 3-tuple of floats or None
349351 Changes the physical dimensions of the Axes3D, such that the ratio
350352 of the axis lengths in display units is x:y:z.
353+ If None, defaults to (4,4,3).
351354
352- If None, defaults to 4:4:3
353-
354- zoom : float
355- Control overall size of the Axes3D in the figure.
355+ zoom : float, default: 1
356+ Control overall size of the Axes3D in the figure. Must be > 0.
356357 """
358+ if zoom <= 0 :
359+ raise ValueError (f'Argument zoom = { zoom } must be > 0' )
360+
357361 if aspect is None :
358362 aspect = np .asarray ((4 , 4 , 3 ), dtype = float )
359363 else :
@@ -964,7 +968,7 @@ def view_init(self, elev=None, azim=None, roll=None, vertical_axis="z"):
964968 The axis to align vertically. *azim* rotates about this axis.
965969 """
966970
967- self .dist = 10
971+ self ._dist = 10 # The camera distance from origin. Behaves like zoom
968972
969973 if elev is None :
970974 self .elev = self .initial_elev
@@ -1039,7 +1043,7 @@ def get_proj(self):
10391043
10401044 # The coordinates for the eye viewing point. The eye is looking
10411045 # towards the middle of the box of data from a distance:
1042- eye = R + self .dist * ps
1046+ eye = R + self ._dist * ps
10431047
10441048 # TODO: Is this being used somewhere? Can it be removed?
10451049 self .eye = eye
@@ -1053,7 +1057,7 @@ def get_proj(self):
10531057 V [self ._vertical_axis ] = - 1 if abs (elev_rad ) > 0.5 * np .pi else 1
10541058
10551059 viewM = proj3d .view_transformation (eye , R , V , roll_rad )
1056- projM = self ._projection (- self .dist , self .dist )
1060+ projM = self ._projection (- self ._dist , self ._dist )
10571061 M0 = np .dot (viewM , worldM )
10581062 M = np .dot (projM , M0 )
10591063 return M
0 commit comments