@@ -53,6 +53,8 @@ class Axes3D(Axes):
53
53
_axis_names = ("x" , "y" , "z" )
54
54
Axes ._shared_axes ["z" ] = cbook .Grouper ()
55
55
56
+ dist = _api .deprecate_privatize_attribute ("3.6" )
57
+
56
58
def __init__ (
57
59
self , fig , rect = None , * args ,
58
60
elev = 30 , azim = - 60 , roll = 0 , sharez = None , proj_type = 'persp' ,
@@ -198,10 +200,10 @@ def convert_zunits(self, z):
198
200
def set_top_view (self ):
199
201
# this happens to be the right view for the viewing coordinates
200
202
# moved up and to the left slightly to fit labels and axes
201
- xdwl = 0.95 / self .dist
202
- xdw = 0.9 / self .dist
203
- ydwl = 0.95 / self .dist
204
- ydw = 0.9 / self .dist
203
+ xdwl = 0.95 / self ._dist
204
+ xdw = 0.9 / self ._dist
205
+ ydwl = 0.95 / self ._dist
206
+ ydw = 0.9 / self ._dist
205
207
# This is purposely using the 2D Axes's set_xlim and set_ylim,
206
208
# because we are trying to place our viewing pane.
207
209
super ().set_xlim (- xdwl , xdw , auto = None )
@@ -349,12 +351,14 @@ def set_box_aspect(self, aspect, *, zoom=1):
349
351
aspect : 3-tuple of floats or None
350
352
Changes the physical dimensions of the Axes3D, such that the ratio
351
353
of the axis lengths in display units is x:y:z.
354
+ If None, defaults to (4,4,3).
352
355
353
- If None, defaults to 4:4:3
354
-
355
- zoom : float
356
- Control overall size of the Axes3D in the figure.
356
+ zoom : float, default: 1
357
+ Control overall size of the Axes3D in the figure. Must be > 0.
357
358
"""
359
+ if zoom <= 0 :
360
+ raise ValueError (f'Argument zoom = { zoom } must be > 0' )
361
+
358
362
if aspect is None :
359
363
aspect = np .asarray ((4 , 4 , 3 ), dtype = float )
360
364
else :
@@ -1006,7 +1010,7 @@ def view_init(self, elev=None, azim=None, roll=None, vertical_axis="z"):
1006
1010
The axis to align vertically. *azim* rotates about this axis.
1007
1011
"""
1008
1012
1009
- self .dist = 10
1013
+ self ._dist = 10 # The camera distance from origin. Behaves like zoom
1010
1014
1011
1015
if elev is None :
1012
1016
self .elev = self .initial_elev
@@ -1081,7 +1085,7 @@ def get_proj(self):
1081
1085
1082
1086
# The coordinates for the eye viewing point. The eye is looking
1083
1087
# towards the middle of the box of data from a distance:
1084
- eye = R + self .dist * ps
1088
+ eye = R + self ._dist * ps
1085
1089
1086
1090
# TODO: Is this being used somewhere? Can it be removed?
1087
1091
self .eye = eye
@@ -1095,7 +1099,7 @@ def get_proj(self):
1095
1099
V [self ._vertical_axis ] = - 1 if abs (elev_rad ) > 0.5 * np .pi else 1
1096
1100
1097
1101
viewM = proj3d .view_transformation (eye , R , V , roll_rad )
1098
- projM = self ._projection (- self .dist , self .dist )
1102
+ projM = self ._projection (- self ._dist , self ._dist )
1099
1103
M0 = np .dot (viewM , worldM )
1100
1104
M = np .dot (projM , M0 )
1101
1105
return M
0 commit comments