Open In App

Matplotlib.axes.Axes.get_zorder() in Python

Improve
Improve
Like Article
Like
Save
Share
Report

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.get_zorder() Function

The Axes.get_zorder() function in axes module of matplotlib library is used to get the artist’s zorder.

Syntax: Axes.get_zorder(self)

Parameters: This method does not accepts any parameter.

Returns: This method return the artist’s zorder.

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

Example 1:




# Implementation of matplotlib function
import numpy as np
import matplotlib.pyplot as plt
    
d = np.arange(100).reshape(10, 10)
xx, yy = np.meshgrid(np.arange(11), np.arange(11))
    
fig, ax = plt.subplots()
    
ax.set_aspect(1)
ax.pcolormesh(xx, yy, d)
  
ax.text(3, 9.5, "Zorder Value : "
        + str(ax.get_zorder()),
        fontweight ="bold")
  
fig.suptitle('matplotlib.axes.Axes.get_zorder() \
function Example', fontweight ="bold")
  
plt.show()


Output:

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()
    
ax.pcolor(xx)
ax.set_zorder(-20)
  
ax.set_title("Zorder Value : "
             + str(ax.get_zorder()))
  
fig.suptitle('matplotlib.axes.Axes.get_zorder() \
function Example', fontweight ="bold")
  
plt.show()


Output:



Last Updated : 30 Apr, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads