Python中的 Matplotlib.figure.Figure.draw()
Matplotlib是Python中的一个库,它是 NumPy 库的数值数学扩展。 figure 模块提供了顶级 Artist,即 Figure,其中包含所有绘图元素。该模块用于控制所有绘图元素的子图和顶级容器的默认间距。
matplotlib.figure.Figure.draw()函数
matplotlib 库的 draw() 方法图形模块用于使用 matplotlib.backend_bases.RendererBase 实例渲染器渲染图形。
Syntax: draw(self, renderer)
Parameters: This accept the following parameters that are described below:
- renderer: This parameter is the matplotlib.backend_bases.RendererBase instance renderer.
Returns: This method does not return any value.
下面的示例说明了 matplotlib.figure 中的 matplotlib.figure.Figure.draw()函数:
示例 1:
# Implementation of matplotlib function
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
fig.draw(renderer)
tellme('matplotlib.figure.Figure.draw() \
function Example')
plt.show()
输出:
示例 2:
# Implementation of matplotlib function
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
fig.draw(renderer)
plt.pause(.001)
fig.suptitle('matplotlib.figure.Figure.draw() \
function Example')
输出: