Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Artist class contains Abstract base class for objects that render into a FigureCanvas. All visible elements in a figure are subclasses of Artist.
matplotlib.artist.Artist.draw() method
The draw() method in the artist module of the matplotlib library is used to draw the Artist using the given renderer.
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.
Below examples illustrate the matplotlib.artist.Artist.draw() function in matplotlib:
Example 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() |
Output:
Example 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() |
Output: