Adjust the Axes for a specified data aspect ratio.
Depending on get_adjustable this will modify either the Axes box (position) or the view limits. In the former case, get_anchor will affect the position.
Note
This parameter exists for historic reasons and is considered internal. End users should not use it.
If not None, this defines the position of the Axes within the figure as a Bbox. See get_position for further details.
See also
matplotlib.axes.Axes.set_aspectFor a description of aspect ratio handling.
matplotlib.axes.Axes.set_adjustableSet how the Axes adjusts to achieve the required aspect ratio.
matplotlib.axes.Axes.set_anchorSet the position in case of extra space.
matplotlib.figure.Figure.draw_without_renderingUpdate all stale components of a figure.
This is called automatically when each Axes is drawn. You may need to call it yourself if you need to update the Axes position and/or view limits before the Figure is drawn.
An alternative with a broader scope is Figure.draw_without_rendering, which updates all stale components of a figure, not only the positioning / view limits of a single Axes.
A typical usage example would be the following. imshow sets the aspect to 1, but adapting the Axes position and extent to reflect this is deferred until rendering for performance reasons. If you want to know the Axes size before, you need to call apply_aspect to get the correct values.
>>> fig, ax = plt.subplots() >>> ax.imshow(np.zeros((3, 3))) >>> ax.bbox.width, ax.bbox.height (496.0, 369.59999999999997) >>> ax.apply_aspect() >>> ax.bbox.width, ax.bbox.height (369.59999999999997, 369.59999999999997)
© 2012–2023 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/stable/api/_as_gen/mpl_toolkits.mplot3d.axes3d.Axes3D.apply_aspect.html