Saturday, November 16, 2024
Google search engine
HomeLanguagesMatplotlib.axis.Axis.get_gid() function in Python

Matplotlib.axis.Axis.get_gid() 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_gid() Function

The Axis.get_gid() function in axis module of matplotlib library is used to get the group id. 
 

Syntax: Axis.get_gid(self) 
 

Parameters: This method does not accepts any parameter. 
 

Return value: This method return the group id. 

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

Example 1:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np  
import matplotlib.pyplot as plt  
       
      
y, x = np.mgrid[:5, 1:6]  
    
poly_coords = [  
    (0.25, 2.75), (3.25, 2.75),  
    (2.25, 0.75), (0.25, 0.75)  
]  
      
fig, ax = plt.subplots()  
       
cells = ax.plot(x, y, x + y, color ='green')  
    
ax.add_patch(  
    plt.Polygon(poly_coords,   
                color ='forestgreen',   
                alpha = 0.5)  
    )  
    
ax.margins(x = 0.1, y = 0.05)  
ax.set_aspect('equal')  
      
for i, t in enumerate(ax.patches):  
    Axis.set_gid(t, 'patch_% d' % i) 
    print("Value Return :", Axis.get_gid(t))
            
fig.suptitle("""matplotlib.axis.Axis.get_gid()
function Example\n""", fontweight ="bold")  
    
plt.show()


Output: 
 

 

Value Return : patch_ 0

Example 2:

Python3




# Implementation of matplotlib function
from matplotlib.axis import Axis
import numpy as np  
import matplotlib.pyplot as plt  
      
       
fig, ax = plt.subplots()  
      
circle = plt.Circle((0, 0), 5, fc ='blue')  
rect = plt.Rectangle((-5, 10), 10, 5, fc ='green')  
      
ax.add_patch(circle)  
ax.add_patch(rect)  
      
circle_tip = ax.annotate('This is a blue circle.',  
            xy =(0, 0),  
            xytext =(30, -30),  
            textcoords ='offset points',  
            color ='w',  
            ha ='left',  
            bbox = dict(boxstyle ='round, pad =.5',   
                        fc =(.1, .1, .1, .92),  
                        ec =(1., 1., 1.),   
                        lw = 1,  
                        zorder = 1),  
            )  
      
rect_tip = ax.annotate('This is a green rectangle.',  
            xy =(-5, 10),  
            xytext =(30, 40),  
            textcoords ='offset points',  
            color ='w',  
            ha ='left',  
            bbox = dict(boxstyle ='round, pad =.5',  
                        fc =(.1, .1, .1, .92),   
                        ec =(1., 1., 1.),   
                        lw = 1,  
                        zorder = 1),  
            )  
    
print("Value Return :")  
for i, t in enumerate(ax.patches):  
    Axis.set_gid(t, 'patch_% d'% i) 
    print(Axis.get_gid(t))  
      
for i, t in enumerate(ax.texts):  
    Axis.set_gid(t, 'tooltip_% d'% i) 
    print(Axis.get_gid(t))  
      
ax.set_xlim(-30, 30)  
ax.set_ylim(-30, 30)  
ax.set_aspect('equal'
            
fig.suptitle("""matplotlib.axis.Axis.get_gid()
function Example\n""", fontweight ="bold")  
    
plt.show()


Output: 
 

 

Value Return :
patch_ 0
patch_ 1
tooltip_ 0
tooltip_ 1

 

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

Most Popular

Recent Comments