Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.
matplotlib.axes.Axes.redraw_in_frame() Function
The Axes.redraw_in_frame() function in axes module of matplotlib library is used to efficiently update Axes data.
Syntax: Axes.redraw_in_frame(self)
Parameters: This method does not accepts any parameters.
Returns: This method does not return any value.
Note: This method can only be used after an initial draw which caches the renderer.
Below examples illustrate the matplotlib.axes.Axes.redraw_in_frame() function in matplotlib.axes:
Example 1:
# Implementation of matplotlib function import matplotlib.pyplot as plt fig, ax = plt.subplots() def tellme(s): ax.set_title(s, fontsize = 12 , fontweight = "bold" ) fig.canvas.draw() ax.redraw_in_frame() tellme('matplotlib.axes.Axes.redraw_in_frame() function \ Example') plt.show() |
Output:
Example 2:
# Implementation of matplotlib function import matplotlib.pyplot as plt import numpy as np import time fig, ax = plt.subplots() line, = ax.plot(np.random.randn( 100 )) tstart = time.time() num_plots = 0 fig.canvas.draw() while time.time() - tstart < 5 : line.set_ydata(np.random.randn( 100 )) ax.redraw_in_frame() num_plots + = 1 ax.set_title('matplotlib.axes.Axes.redraw_in_frame() \ function Example') plt.show() |
Output: