Matplotlib.axes.Axes.get_rasterization_zorder() in Python
Last Updated :
30 Apr, 2020
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_rasterization_zorder() Function
The Axes.get_rasterization_zorder() function in axes module of matplotlib library is used to return the zorder value below which artists will be rasterized.
Syntax: Axes.get_rasterization_zorder(self)
Parameters: This method does not accepts any parameters.
Returns: This method return the zorder value below which artists will be rasterized.
Below examples illustrate the matplotlib.axes.Axes.get_rasterization_zorder() function in matplotlib.axes:
Example 1:
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 )
m = ax.pcolormesh(xx, yy, d)
m.set_zorder( - 15 )
ax.set_rasterization_zorder( - 5 )
w = ax.get_rasterization_zorder()
ax.text( 2 , 9.5 , "Rasterization Zorder Value : " + str (w))
fig.suptitle('matplotlib.axes.Axes.get_rasterization_zorder() \
function Example', fontweight = "bold" )
plt.show()
|
Output:
Example 2:
import numpy as np
import matplotlib.pyplot as plt
xx = np.random.rand( 16 , 30 )
fig, (ax3, ax4) = plt.subplots( 1 , 2 )
m = ax3.pcolor(xx)
m.set_zorder( - 20 )
w = ax3.get_rasterization_zorder()
ax3.set_title( "Rasterization Zorder Value : " + str (w))
m = ax4.pcolor(xx)
m.set_zorder( - 20 )
ax4.set_rasterization_zorder( - 10 )
w = ax4.get_rasterization_zorder()
ax4.set_title( "Rasterization Zorder Value : " + str (w))
fig.suptitle('matplotlib.axes.Axes.get_rasterization_zorder()\
function Example', fontweight = "bold" )
plt.show()
|
Output:
Share your thoughts in the comments
Please Login to comment...