@@ -129,6 +129,9 @@ def __init__(
129
129
# they can't be defined until Axes.__init__ has been called
130
130
self .view_init (self .initial_elev , self .initial_azim , self .initial_roll )
131
131
132
+ # set the initial zoom level
133
+ self .zoom = 1
134
+
132
135
self ._sharez = sharez
133
136
if sharez is not None :
134
137
self ._shared_axes ["z" ].join (self , sharez )
@@ -329,7 +332,7 @@ def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
329
332
super ().set_aspect (
330
333
aspect , adjustable = adjustable , anchor = anchor , share = share )
331
334
332
- def set_box_aspect (self , aspect , * , zoom = 1 ):
335
+ def set_box_aspect (self , aspect = None , * , zoom = None ):
333
336
"""
334
337
Set the axes box aspect.
335
338
@@ -346,22 +349,27 @@ def set_box_aspect(self, aspect, *, zoom=1):
346
349
347
350
Parameters
348
351
----------
349
- aspect : 3-tuple of floats or None
352
+ aspect : 3-tuple of floats or None, default: (4:4:3)
350
353
Changes the physical dimensions of the Axes3D, such that the ratio
351
354
of the axis lengths in display units is x:y:z.
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: None
357
+ Control overall size of the Axes3D in the figure. A value of None
358
+ keeps the current zoom level.
357
359
"""
360
+ # self.zoom is first set in Axes3D init
361
+ if zoom is not None :
362
+ if zoom <= 0 :
363
+ raise ValueError (f'Argument zoom = { zoom } must be > 0' )
364
+ self .zoom = zoom
365
+
358
366
if aspect is None :
359
367
aspect = np .asarray ((4 , 4 , 3 ), dtype = float )
360
368
else :
361
369
aspect = np .asarray (aspect , dtype = float )
362
370
_api .check_shape ((3 ,), aspect = aspect )
363
371
# default scale tuned to match the mpl32 appearance.
364
- aspect *= 1.8294640721620434 * zoom / np .linalg .norm (aspect )
372
+ aspect *= 1.8294640721620434 * self . zoom / np .linalg .norm (aspect )
365
373
366
374
self ._box_aspect = aspect
367
375
self .stale = True
@@ -1006,7 +1014,7 @@ def view_init(self, elev=None, azim=None, roll=None, vertical_axis="z"):
1006
1014
The axis to align vertically. *azim* rotates about this axis.
1007
1015
"""
1008
1016
1009
- self .dist = 10
1017
+ self .dist = 10 # The camera distance from origin. Behaves like zoom
1010
1018
1011
1019
if elev is None :
1012
1020
self .elev = self .initial_elev
0 commit comments