Matplotlib.artist.artist.set_zorder()
Python matplotlib库的artist模块中的set_zorder()方法用于为artist设置zorder。
语法:Artist.set_zorder(self, level)
参数:该方法接受以下参数。
- 级别:包含float值。
Returns:该方法不返回任何值。
下面的例子说明了matplotlib中的matplotlib.artist.artist.set_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)
m = ax.pcolormesh(xx, yy, d)
Artist.set_zorder(m, -15)
fig.suptitle('matplotlib.artist.Artist.set_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, (ax3, ax4) = plt.subplots(1, 2)
m = ax3.pcolor(xx)
ax3.set_title("No Zorder value ")
m = ax4.pcolor(xx)
Artist.set_zorder(m, -20)
ax4.set_title("Zorder Value : -20")
fig.suptitle('matplotlib.artist.Artist.set_zorder()\
function Example', fontweight ="bold")
plt.show()
输出: