Skip to content

Commit 90bce73

Browse files
Clean up 3d plot box_aspect zooming
linting Cleanup
1 parent 92989c3 commit 90bce73

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -346,22 +346,25 @@ def set_box_aspect(self, aspect, *, zoom=1):
346346
347347
Parameters
348348
----------
349-
aspect : 3-tuple of floats or None
349+
aspect : 3-tuple of floats or None, default: None
350350
Changes the physical dimensions of the Axes3D, such that the ratio
351351
of the axis lengths in display units is x:y:z.
352+
If None, defaults to (4,4,3)
352353
353-
If None, defaults to 4:4:3
354-
355-
zoom : float
354+
zoom : float, default: 1
356355
Control overall size of the Axes3D in the figure.
357356
"""
357+
if zoom <= 0:
358+
raise ValueError(f'Argument zoom = {zoom} must be > 0')
359+
self.zoom = zoom
360+
358361
if aspect is None:
359362
aspect = np.asarray((4, 4, 3), dtype=float)
360363
else:
361364
aspect = np.asarray(aspect, dtype=float)
362365
_api.check_shape((3,), aspect=aspect)
363366
# default scale tuned to match the mpl32 appearance.
364-
aspect *= 1.8294640721620434 * zoom / np.linalg.norm(aspect)
367+
aspect *= 1.8294640721620434 * self.zoom / np.linalg.norm(aspect)
365368

366369
self._box_aspect = aspect
367370
self.stale = True
@@ -1006,7 +1009,7 @@ def view_init(self, elev=None, azim=None, roll=None, vertical_axis="z"):
10061009
The axis to align vertically. *azim* rotates about this axis.
10071010
"""
10081011

1009-
self.dist = 10
1012+
self.dist = 10 # The camera distance from origin. Behaves like zoom
10101013

10111014
if elev is None:
10121015
self.elev = self.initial_elev

0 commit comments

Comments
 (0)