matplotlib.artist.Artist.get_window_extent#

Artist.get_window_extent(renderer=None)[source]#

Get the artist's bounding box in display space, ignoring clipping.

The bounding box's width and height are non-negative.

Subclasses should override for inclusion in the bounding box "tight"calculation. Default is to return an empty bounding box at 0, 0.

Warning

The extent can change due to any changes in the transform stack, suchas changing the Axes limits, the figure size, the canvas used (as isdone when saving a figure), or the DPI.

Relying on a once-retrieved window extent can lead to unexpectedbehavior in various cases such as interactive figures being resized ormoved to a screen with different dpi, or figures that look fine onscreen render incorrectly when saved to file.

To get accurate results you may need to manually callsavefig ordraw_without_rendering to haveMatplotlib compute the rendered size.

Parameters:
rendererRendererBase, optional

Renderer used to draw the figure (i.e.fig.canvas.get_renderer()).

See also

Artist.get_tightbbox

Get the artist bounding box, taking clipping into account.

Examples usingmatplotlib.artist.Artist.get_window_extent#

BboxImage Demo

BboxImage Demo

Programmatically control subplot adjustment

Programmatically control subplot adjustment

Annotations

Annotations