Matplotlib.artist.artist.get_zorder()
Python matplotlib库的artist模块中的get_zorder()方法用于获取artist的zorder。
语法:Artist.get_zorder(self)
参数:该方法不接受任何参数。
这个方法返回artist的zorder。
下面的例子说明了matplotlib中的matplotlib.artist.artist.get_zorder()函数:
示例1
# Implementation of matplotlib function
from matplotlib.artist import Artist
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(Artist.get_zorder(ax)),
fontweight ="bold")
fig.suptitle('matplotlib.artist.Artist.get_zorder()\
function Example', fontweight ="bold")
plt.show()
输出:
示例2
# Implementation of matplotlib function
from matplotlib.artist import Artist
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(Artist.get_zorder(ax)),
fontweight ="bold")
fig.suptitle('matplotlib.artist.Artist.get_zorder()\
function Example', fontweight ="bold")
plt.show()
输出: