@@ -52,6 +52,8 @@ class Axes3D(Axes):
52
52
_axis_names = ("x" , "y" , "z" )
53
53
Axes ._shared_axes ["z" ] = cbook .Grouper ()
54
54
55
+ dist = _api .deprecate_privatize_attribute ("3.6" )
56
+
55
57
def __init__ (
56
58
self , fig , rect = None , * args ,
57
59
elev = 30 , azim = - 60 , roll = 0 , sharez = None , proj_type = 'persp' ,
@@ -197,10 +199,10 @@ def convert_zunits(self, z):
197
199
def set_top_view (self ):
198
200
# this happens to be the right view for the viewing coordinates
199
201
# 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
204
206
# This is purposely using the 2D Axes's set_xlim and set_ylim,
205
207
# because we are trying to place our viewing pane.
206
208
super ().set_xlim (- xdwl , xdw , auto = None )
@@ -348,12 +350,14 @@ def set_box_aspect(self, aspect, *, zoom=1):
348
350
aspect : 3-tuple of floats or None
349
351
Changes the physical dimensions of the Axes3D, such that the ratio
350
352
of the axis lengths in display units is x:y:z.
353
+ If None, defaults to (4,4,3).
351
354
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.
356
357
"""
358
+ if zoom <= 0 :
359
+ raise ValueError (f'Argument zoom = { zoom } must be > 0' )
360
+
357
361
if aspect is None :
358
362
aspect = np .asarray ((4 , 4 , 3 ), dtype = float )
359
363
else :
@@ -964,7 +968,7 @@ def view_init(self, elev=None, azim=None, roll=None, vertical_axis="z"):
964
968
The axis to align vertically. *azim* rotates about this axis.
965
969
"""
966
970
967
- self .dist = 10
971
+ self ._dist = 10 # The camera distance from origin. Behaves like zoom
968
972
969
973
if elev is None :
970
974
self .elev = self .initial_elev
@@ -1039,7 +1043,7 @@ def get_proj(self):
1039
1043
1040
1044
# The coordinates for the eye viewing point. The eye is looking
1041
1045
# towards the middle of the box of data from a distance:
1042
- eye = R + self .dist * ps
1046
+ eye = R + self ._dist * ps
1043
1047
1044
1048
# TODO: Is this being used somewhere? Can it be removed?
1045
1049
self .eye = eye
@@ -1053,7 +1057,7 @@ def get_proj(self):
1053
1057
V [self ._vertical_axis ] = - 1 if abs (elev_rad ) > 0.5 * np .pi else 1
1054
1058
1055
1059
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 )
1057
1061
M0 = np .dot (viewM , worldM )
1058
1062
M = np .dot (projM , M0 )
1059
1063
return M
0 commit comments