MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / set_box_aspect

Method set_box_aspect

lib/mpl_toolkits/mplot3d/axes3d.py:397–436  ·  view source on GitHub ↗

Set the Axes box aspect. The box aspect is the ratio of height to width in display units for each face of the box when viewed perpendicular to that face. This is not to be confused with the data aspect (see `~.Axes3D.set_aspect`). The default ratios are 4:4

(self, aspect, *, zoom=1)

Source from the content-addressed store, hash-verified

395 return ax_indices
396
397 def set_box_aspect(self, aspect, *, zoom=1):
398 """
399 Set the Axes box aspect.
400
401 The box aspect is the ratio of height to width in display
402 units for each face of the box when viewed perpendicular to
403 that face. This is not to be confused with the data aspect (see
404 `~.Axes3D.set_aspect`). The default ratios are 4:4:3 (x:y:z).
405
406 To simulate having equal aspect in data space, set the box
407 aspect to match your data range in each dimension.
408
409 *zoom* controls the overall size of the Axes3D in the figure.
410
411 Parameters
412 ----------
413 aspect : 3-tuple of floats or None
414 Changes the physical dimensions of the Axes3D, such that the ratio
415 of the axis lengths in display units is x:y:z.
416 If None, defaults to (4, 4, 3).
417
418 zoom : float, default: 1
419 Control overall size of the Axes3D in the figure. Must be > 0.
420 """
421 if zoom <= 0:
422 raise ValueError(f'Argument zoom = {zoom} must be > 0')
423
424 if aspect is None:
425 aspect = np.asarray((4, 4, 3), dtype=float)
426 else:
427 aspect = np.asarray(aspect, dtype=float)
428 _api.check_shape((3,), aspect=aspect)
429 # The scale 1.8294640721620434 is tuned to match the mpl3.2 appearance.
430 # The 25/24 factor is to compensate for the change in automargin
431 # behavior in mpl3.9. This comes from the padding of 1/48 on both sides
432 # of the axes in mpl3.8.
433 aspect *= 1.8294640721620434 * 25/24 * zoom / np.linalg.norm(aspect)
434
435 self._box_aspect = self._roll_to_vertical(aspect, reverse=True)
436 self.stale = True
437
438 def apply_aspect(self, position=None):
439 if position is None:

Callers 4

set_aspectMethod · 0.95
test_aspectsFunction · 0.45
test_equal_box_aspectFunction · 0.45

Calls 2

_roll_to_verticalMethod · 0.95
normMethod · 0.45

Tested by 3

test_aspectsFunction · 0.36
test_equal_box_aspectFunction · 0.36