matplotlib.artist.Artist.get_window_extent#

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

Get the artist's bounding box in display space.

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, such as changing the Axes limits, the figure size, the canvas used (as is done when saving a figure), or the DPI.

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

To get accurate results you may need to manually call matplotlib.figure.Figure.savefig or matplotlib.figure.Figure.draw_without_rendering to have Matplotlib compute the rendered size.

Examples using matplotlib.artist.Artist.get_window_extent#

BboxImage Demo

BboxImage Demo

Programmatically control subplot adjustment

Programmatically control subplot adjustment

Annotations

Annotations