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

Method set_aspect

lib/mpl_toolkits/mplot3d/axes3d.py:298–374  ·  view source on GitHub ↗

Set the aspect ratios. Parameters ---------- aspect : {'auto', 'equal', 'equalxy', 'equalxz', 'equalyz'} Possible values: ========= ================================================== value description ========

(self, aspect, adjustable=None, anchor=None, share=False)

Source from the content-addressed store, hash-verified

296 @_api.delete_parameter("3.11", "share")
297 @_api.delete_parameter("3.11", "anchor")
298 def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
299 """
300 Set the aspect ratios.
301
302 Parameters
303 ----------
304 aspect : {'auto', 'equal', 'equalxy', 'equalxz', 'equalyz'}
305 Possible values:
306
307 ========= ==================================================
308 value description
309 ========= ==================================================
310 'auto' automatic; fill the position rectangle with data.
311 'equal' adapt all the axes to have equal aspect ratios.
312 'equalxy' adapt the x and y axes to have equal aspect ratios.
313 'equalxz' adapt the x and z axes to have equal aspect ratios.
314 'equalyz' adapt the y and z axes to have equal aspect ratios.
315 ========= ==================================================
316
317 adjustable : {'box', 'datalim'}, default: 'box'
318 Defines which parameter to adjust to meet the aspect ratio.
319
320 - 'box': Change the physical dimensions of the axes bounding box.
321 - 'datalim': Change the x, y, or z data limits.
322
323 anchor : None or str or 2-tuple of float, optional
324 .. deprecated:: 3.11
325 This parameter has no effect.
326
327 share : bool, default: False
328 .. deprecated:: 3.11
329 This parameter has no effect.
330
331 See Also
332 --------
333 mpl_toolkits.mplot3d.axes3d.Axes3D.set_box_aspect
334 """
335 if adjustable is None:
336 adjustable = 'box'
337 _api.check_in_list(['box', 'datalim'], adjustable=adjustable)
338 _api.check_in_list(('auto', 'equal', 'equalxy', 'equalyz', 'equalxz'),
339 aspect=aspect)
340
341 self.set_adjustable(adjustable)
342 self._aspect = aspect
343
344 if aspect in ('equal', 'equalxy', 'equalxz', 'equalyz'):
345 ax_indices = self._equal_aspect_axis_indices(aspect)
346
347 view_intervals = np.array([self.xaxis.get_view_interval(),
348 self.yaxis.get_view_interval(),
349 self.zaxis.get_view_interval()])
350 ptp = np.ptp(view_intervals, axis=1)
351 if self._adjustable == 'datalim':
352 mean = np.mean(view_intervals, axis=1)
353 scale = max(ptp[ax_indices] / self._box_aspect[ax_indices])
354 deltas = scale * self._box_aspect
355

Callers 3

test_aspectsFunction · 0.45
test_aspects_adjust_boxFunction · 0.45

Calls 6

set_box_aspectMethod · 0.95
set_adjustableMethod · 0.80
get_view_intervalMethod · 0.45
popMethod · 0.45
normMethod · 0.45

Tested by 3

test_aspectsFunction · 0.36
test_aspects_adjust_boxFunction · 0.36