Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3b5dc22

Browse filesBrowse files
committed
Parameter checks and documentation updates.
1 parent 8289471 commit 3b5dc22
Copy full SHA for 3b5dc22

File tree

Expand file treeCollapse file tree

1 file changed

+9
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-12
lines changed

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
+9-12Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,9 @@ def set_aspect(self, aspect, adjustable='datalim', anchor=None,
287287
'equalyz' adapt the y and z axes to have equal aspect ratios.
288288
========= ==================================================
289289
290-
adjustable : None
291-
Currently ignored by Axes3D
292-
293-
If not *None*, this defines which parameter will be adjusted to
294-
meet the required aspect. See `.set_adjustable` for further
295-
details.
290+
adjustable : {'datalim', 'box'}, default: 'datalim'
291+
This defines which parameter will be adjusted to meet the required
292+
aspect. See `.set_adjustable` for further details.
296293
297294
anchor : None or str or 2-tuple of float, optional
298295
If not *None*, this defines where the Axes will be drawn if there
@@ -320,6 +317,7 @@ def set_aspect(self, aspect, adjustable='datalim', anchor=None,
320317
"""
321318
_api.check_in_list(('auto', 'equal', 'equalxy', 'equalyz', 'equalxz'),
322319
aspect=aspect)
320+
_api.check_in_list(('datalim', 'box'), adjustable=adjustable)
323321
super().set_aspect(
324322
aspect='auto', adjustable=adjustable, anchor=anchor, share=share)
325323
self._aspect = aspect
@@ -337,9 +335,9 @@ def set_aspect(self, aspect, adjustable='datalim', anchor=None,
337335
view_intervals = np.array([self.xaxis.get_view_interval(),
338336
self.yaxis.get_view_interval(),
339337
self.zaxis.get_view_interval()])
338+
ptp = np.ptp(view_intervals, axis=1)
340339
if adjustable == 'datalim':
341340
mean = np.mean(view_intervals, axis=1)
342-
ptp = np.ptp(view_intervals, axis=1)
343341
delta = max(ptp[ax_indices])
344342
scale = self._box_aspect[ptp == delta][0]
345343
deltas = delta * self._box_aspect / scale
@@ -349,18 +347,17 @@ def set_aspect(self, aspect, adjustable='datalim', anchor=None,
349347
self.set_zlim3d)):
350348
if i in ax_indices:
351349
set_lim(mean[i] - deltas[i]/2., mean[i] + deltas[i]/2.)
352-
elif adjustable == 'box':
350+
else: # 'box'
353351
# Change the box aspect such that the ratio of the length of
354352
# the unmodified axis to the length of the diagonal
355353
# perpendicular to it remains unchanged.
356-
deltas = np.ptp(view_intervals, axis=1)
357-
box_aspect = np.array(self.get_box_aspect())
358-
box_aspect[ax_indices] = deltas[ax_indices]
354+
box_aspect = np.array(self._box_aspect)
355+
box_aspect[ax_indices] = ptp[ax_indices]
359356
remaining_ax_indices = {0, 1, 2}.difference(ax_indices)
360357
if remaining_ax_indices:
361358
remaining_ax_index = remaining_ax_indices.pop()
362359
old_diag = np.linalg.norm(box_aspect[ax_indices])
363-
new_diag = np.linalg.norm(deltas[ax_indices])
360+
new_diag = np.linalg.norm(ptp[ax_indices])
364361
box_aspect[remaining_ax_index] *= new_diag / old_diag
365362
self.set_box_aspect(box_aspect)
366363

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.