Friday, October 24, 2025
HomeLanguagesmatplotlib.axes.Axes.use_sticky_edges() in Python

matplotlib.axes.Axes.use_sticky_edges() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.

matplotlib.axes.Axes.use_sticky_edges() Function

The Axes.use_sticky_edges() function in axes module of matplotlib library is used whether to obey all Artist.sticky_edges.

Syntax:

Axes.use_sticky_edges

Below examples illustrate the matplotlib.axes.Axes.use_sticky_edges() function in matplotlib.axes:

Example 1:




# Implementation of matplotlib function  
import numpy as np
import matplotlib.pyplot as plt
  
y, x = np.mgrid[:6, 1:6]
poly_coords = [
    (0.25, 2.75), (3.25, 2.75),
    (2.25, 0.75), (0.25, 0.75)
]
fig, ax = plt.subplots()
  
ax.use_sticky_edges = False
  
ax.pcolor(x, y, y + 20 * x, cmap ='Greens')
  
ax.margins(x = 0.1, y = 0.05)
ax.set_aspect('equal')
  
fig.suptitle('matplotlib.axes.Axes.use_sticky_edges() \
function Example\n', fontweight ="bold")
fig.canvas.draw()
plt.show()


Output:

Example 2:




# Implementation of matplotlib function  
import numpy as np
import matplotlib.pyplot as plt
  
y, x = np.mgrid[:6, 1:6]
poly_coords = [
    (0.25, 2.75), (3.25, 2.75),
    (2.25, 0.75), (0.25, 0.75)
]
fig, (ax1, ax2) = plt.subplots(nrows = 2)
  
ax2.use_sticky_edges = False
  
for ax, status in zip((ax1, ax2), 
                      ('Is', 'Is Not')):
      
    # sticky
    cells = ax.pcolor(x, y, x + y, 
                      cmap ='PuBuGn')
    ax.add_patch(
        plt.Polygon(poly_coords, color ='green',
                    alpha = 0.5)
    # not sticky
    ax.margins(x = 0.1, y = 0.05)
    ax.set_aspect('equal')
    ax.set_title('use_sticky_edges() function {} used'.format(status), 
                 fontweight ="bold")
  
fig.suptitle('matplotlib.axes.Axes.use_sticky_edges() function \
Example\n', fontweight ="bold")
fig.canvas.draw()
plt.show()


Output:

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

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS