Friday, November 21, 2025
HomeLanguagesMatplotlib.axis.Axis.get_tightbbox() function in Python

Matplotlib.axis.Axis.get_tightbbox() function in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. It is an amazing visualization library in Python for 2D plots of arrays and used for working with the broader SciPy stack.

Matplotlib.axis.Axis.get_tightbbox() Function

The Axis.get_tightbbox() function in axis module of matplotlib library is used to get the bounding box that encloses the axis.

Syntax: Axis.get_tightbbox(self, renderer) 
 

Parameters: This method accepts the following parameters. 

  • renderer: This parameter is the RendererBase instance 
    renderer

Return value: This method returns the bounding box that encloses the axis. 

Below examples illustrate the matplotlib.axis.Axis.get_tightbbox() function in matplotlib.axis:
 

Example 1:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
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 = Axis.get_tightbbox(ax.xaxis, fig.canvas.get_renderer()) 
    
print("Value Return :\n"+str(w)) 
ax.grid()
    
fig.suptitle("""matplotlib.axis.Axis.get_tightbbox()
function Example\n""", fontweight ="bold")  
        
plt.show()


Output: 

 

Value Return :
Bbox(x0=75.48368298368294, y0=29.077777777777776, x1=574.7670454545455, y1=43.077777777777776)

Example 2:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np  
import matplotlib.pyplot as plt  
       
xx = np.random.rand(8, 6)  
       
fig, ax = plt.subplots()  
       
m = ax.pcolor(xx)  
m.set_zorder(-2)  
w = Axis.get_tightbbox(ax.xaxis, fig.canvas.get_renderer()) 
    
print("Value Return :\n"+str(w)) 
ax.grid()
    
fig.suptitle("""matplotlib.axis.Axis.get_tightbbox()
function Example\n""", fontweight ="bold")  
        
plt.show()


Output: 

 

Value Return :
Bbox(x0=75.5625, y0=29.077777777777776, x1=580.4375, y1=43.077777777777776)

 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11995 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS