Matplotlib.axes.axes.get_rasterization_zorder()
Matplotlib是Python中的一个库,它是NumPy库的数值-数学扩展。Axes包含了大多数图形元素:Axis、Tick、Line2D、Text、Polygon等,并设置坐标系。Axes的实例通过callbacks属性支持回调。
Matplotlib.axes.axes.get_rasterization_zorder()函数
matplotlib库的Axes模块中的Axes.get_rasterization_zorder()函数用于返回zorder值,低于该值的艺术家将被栅格化。
语法:Axes.get_rasterization_zorder(self)
参数:该方法不接受任何参数。
返回:该方法返回zorder值,艺术家将在该值以下被栅格化。
下面的例子演示了matplotlib.axes.axes.get_rasterization_zorder()函数在matplotlib.axes中的作用:
示例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()
输出: