Matplotlib.artist.artist.draw()
Python matplotlib库的artist模块中的draw()方法用于使用给定的渲染器绘制Artist。
语法:Artist.draw(self, renderer, *args, **kwargs)
参数:该方法接受以下参数。
- renderer:这个参数是RendererBase的子类。
Returns:该方法不返回任何值。
下面的例子说明了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()