Tuesday, July 28, 2026
HomeLanguagesMatplotlib.figure.Figure.get_window_extent() in Python

Matplotlib.figure.Figure.get_window_extent() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements.

matplotlib.figure.Figure.get_window_extent() method

The get_window_extent() method figure module of matplotlib library is used to get the figure bounding box in display space.

Syntax: get_window_extent(self, *args, **kwargs)

Parameters: This method does not accepts any parameter.

Returns: This method return the figure bounding box in display space.

Below examples illustrate the matplotlib.figure.Figure.get_window_extent() function in matplotlib.figure:

Example 1:




# Implementation of matplotlib function
import matplotlib.pyplot as plt
import numpy as np
  
  
X = np.arange(-10, 10, 0.5)
Y = np.arange(-10, 10, 0.5)
U, V = np.meshgrid(X, Y)
     
fig, ax = plt.subplots()
  
ax.quiver(X, Y, U, V)
ax.invert_xaxis() 
  
w = fig.get_window_extent()
   
print("Value Return by get_window_extent():")
print(w)
    
fig.suptitle('matplotlib.figure.Figure.get_window_extent()\
 function Example', fontweight ="bold"
  
plt.show()


Output:

Value Return by get_window_extent():
TransformedBbox(
    Bbox(x0=0.0, y0=0.0, x1=6.4, y1=4.8),
    Affine2D(
        [[100.   0.   0.]
         [  0. 100.   0.]
         [  0.   0.   1.]]))

Example 2:




# Implementation of matplotlib function 
import numpy as np 
import matplotlib.pyplot as plt 
  
  
xx = np.random.rand(16, 30
      
fig, ax = plt.subplots() 
      
m = ax.pcolor(xx) 
m.set_zorder(-20
  
w = fig.get_window_extent()
   
print("Value Return by get_window_extent():")
print(w)
    
fig.suptitle('matplotlib.figure.Figure.get_window_extent()\
 function Example', fontweight ="bold"
  
plt.show()


Output:

Value Return by get_window_extent():
TransformedBbox(
    Bbox(x0=0.0, y0=0.0, x1=6.4, y1=4.8),
    Affine2D(
        [[100.   0.   0.]
         [  0. 100.   0.]
         [  0.   0.   1.]]))
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32520 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6903 POSTS0 COMMENTS
Nicole Veronica
12017 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12115 POSTS0 COMMENTS
Shaida Kate Naidoo
7023 POSTS0 COMMENTS
Ted Musemwa
7265 POSTS0 COMMENTS
Thapelo Manthata
6980 POSTS0 COMMENTS
Umr Jansen
6973 POSTS0 COMMENTS