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, `~matplotlib.axes.Axes.get_anchor` will affect the position. Parameters -------
(self, position=None)
| 1963 | return ysize / xsize |
| 1964 | |
| 1965 | def apply_aspect(self, position=None): |
| 1966 | """ |
| 1967 | Adjust the Axes for a specified data aspect ratio. |
| 1968 | |
| 1969 | Depending on `.get_adjustable` this will modify either the |
| 1970 | Axes box (position) or the view limits. In the former case, |
| 1971 | `~matplotlib.axes.Axes.get_anchor` will affect the position. |
| 1972 | |
| 1973 | Parameters |
| 1974 | ---------- |
| 1975 | position : None or .Bbox |
| 1976 | |
| 1977 | .. note:: |
| 1978 | This parameter exists for historic reasons and is considered |
| 1979 | internal. End users should not use it. |
| 1980 | |
| 1981 | If not ``None``, this defines the position of the |
| 1982 | Axes within the figure as a Bbox. See `~.Axes.get_position` |
| 1983 | for further details. |
| 1984 | |
| 1985 | Notes |
| 1986 | ----- |
| 1987 | This is called automatically when each Axes is drawn. You may need |
| 1988 | to call it yourself if you need to update the Axes position and/or |
| 1989 | view limits before the Figure is drawn. |
| 1990 | |
| 1991 | An alternative with a broader scope is `.Figure.draw_without_rendering`, |
| 1992 | which updates all stale components of a figure, not only the positioning / |
| 1993 | view limits of a single Axes. |
| 1994 | |
| 1995 | See Also |
| 1996 | -------- |
| 1997 | matplotlib.axes.Axes.set_aspect |
| 1998 | For a description of aspect ratio handling. |
| 1999 | matplotlib.axes.Axes.set_adjustable |
| 2000 | Set how the Axes adjusts to achieve the required aspect ratio. |
| 2001 | matplotlib.axes.Axes.set_anchor |
| 2002 | Set the position in case of extra space. |
| 2003 | matplotlib.figure.Figure.draw_without_rendering |
| 2004 | Update all stale components of a figure. |
| 2005 | |
| 2006 | Examples |
| 2007 | -------- |
| 2008 | A typical usage example would be the following. `~.Axes.imshow` sets the |
| 2009 | aspect to 1, but adapting the Axes position and extent to reflect this is |
| 2010 | deferred until rendering for performance reasons. If you want to know the |
| 2011 | Axes size before, you need to call `.apply_aspect` to get the correct |
| 2012 | values. |
| 2013 | |
| 2014 | >>> fig, ax = plt.subplots() |
| 2015 | >>> ax.imshow(np.zeros((3, 3))) |
| 2016 | >>> ax.bbox.width, ax.bbox.height |
| 2017 | (496.0, 369.59999999999997) |
| 2018 | >>> ax.apply_aspect() |
| 2019 | >>> ax.bbox.width, ax.bbox.height |
| 2020 | (369.59999999999997, 369.59999999999997) |
| 2021 | """ |
| 2022 | if position is None: |