Python中的 Matplotlib.artist.Artist.draw()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 Artist 类包含呈现为 FigureCanvas 的对象的 Abstract 基类。图中所有可见元素都是 Artist 的子类。
matplotlib.artist.Artist.draw() 方法
matplotlib 库的艺术家模块中的draw() 方法用于使用给定的渲染器绘制艺术家。
Syntax: Artist.draw(self, renderer, \*args, \*\*kwargs)
Parameters: This method accepts the following parameters.
- renderer: This parameter is the RendererBase subclass.
Returns: This method does not return any value.
下面的示例说明了 matplotlib 中的 matplotlib.artist.Artist.draw()函数:
示例 1:
# Implementation of matplotlib function
from matplotlib.artist import Artist
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
def tellme(s):
ax.set_title(s, fontsize = 16)
fig.canvas.draw()
renderer = fig.canvas.renderer
Artist.draw(ax, renderer)
tellme('matplotlib.artist.Artist.draw() function Example')
ax.grid()
plt.show()
输出:
示例 2:
# Implementation of matplotlib function
from matplotlib.artist import Artist
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection ='3d')
X, Y, Z = axes3d.get_test_data(0.1)
ax.plot_wireframe(X, Y, Z, rstride = 5,
cstride = 5)
for angle in range(0, 90):
ax.view_init(30, angle)
fig.canvas.draw()
renderer = fig.canvas.renderer
Artist.draw(ax, renderer)
plt.pause(.001)
fig.suptitle('matplotlib.artist.Artist.draw() function Example')
ax.grid()
plt.show()
输出: