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 8289471

Browse filesBrowse files
committed
Style fixes. Addressed review comments.
1 parent 2e6edf7 commit 8289471
Copy full SHA for 8289471

File tree

Expand file treeCollapse file tree

1 file changed

+13
-23
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-23
lines changed

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
+13-23Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ def tunit_edges(self, vals=None, M=None):
267267
(tc[7], tc[4])]
268268
return edges
269269

270-
def set_aspect(
271-
self, aspect, adjustable='datalim', anchor=None, share=False):
270+
def set_aspect(self, aspect, adjustable='datalim', anchor=None,
271+
share=False):
272272
"""
273273
Set the aspect ratios.
274274
@@ -350,28 +350,18 @@ def set_aspect(
350350
if i in ax_indices:
351351
set_lim(mean[i] - deltas[i]/2., mean[i] + deltas[i]/2.)
352352
elif adjustable == 'box':
353+
# Change the box aspect such that the ratio of the length of
354+
# the unmodified axis to the length of the diagonal
355+
# perpendicular to it remains unchanged.
353356
deltas = np.ptp(view_intervals, axis=1)
354-
box_aspect = self.get_box_aspect()
355-
if aspect == 'equal':
356-
box_aspect = np.ptp(view_intervals, axis=1)
357-
elif aspect == 'equalxy':
358-
old_diag = box_aspect[0] ** 2 + box_aspect[1] ** 2
359-
new_diag = deltas[0] ** 2 + deltas[1] ** 2
360-
box_aspect[0] = deltas[0]
361-
box_aspect[1] = deltas[1]
362-
box_aspect[2] *= np.sqrt(new_diag / old_diag)
363-
elif aspect == 'equalxz':
364-
old_diag = box_aspect[0] ** 2 + box_aspect[2] ** 2
365-
new_diag = deltas[0] ** 2 + deltas[2] ** 2
366-
box_aspect[0] = deltas[0]
367-
box_aspect[1] *= np.sqrt(new_diag / old_diag)
368-
box_aspect[2] = deltas[2]
369-
elif aspect == 'equalyz':
370-
old_diag = box_aspect[1] ** 2 + box_aspect[2] ** 2
371-
new_diag = deltas[1] ** 2 + deltas[2] ** 2
372-
box_aspect[0] *= np.sqrt(new_diag / old_diag)
373-
box_aspect[1] = deltas[1]
374-
box_aspect[2] = deltas[2]
357+
box_aspect = np.array(self.get_box_aspect())
358+
box_aspect[ax_indices] = deltas[ax_indices]
359+
remaining_ax_indices = {0, 1, 2}.difference(ax_indices)
360+
if remaining_ax_indices:
361+
remaining_ax_index = remaining_ax_indices.pop()
362+
old_diag = np.linalg.norm(box_aspect[ax_indices])
363+
new_diag = np.linalg.norm(deltas[ax_indices])
364+
box_aspect[remaining_ax_index] *= new_diag / old_diag
375365
self.set_box_aspect(box_aspect)
376366

377367
def set_box_aspect(self, aspect, *, zoom=1):

0 commit comments

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