Python中的 Matplotlib.axes.Axes.get_rasterization_zorder()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Axes 类包含大部分图形元素:Axis、Tick、Line2D、Text、Polygon 等,并设置坐标系。 Axes 的实例通过回调属性支持回调。
matplotlib.axes.Axes.get_rasterization_zorder()函数
matplotlib 库的 axes 模块中的Axes.get_rasterization_zorder()函数用于返回艺术家将被光栅化的 zorder 值。
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.
下面的示例说明了 matplotlib.axes 中的 matplotlib.axes.Axes.get_rasterization_zorder()函数:
示例 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)
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()
输出:
示例 2:
# Implementation of matplotlib function
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()
输出: