Friday, September 5, 2025
HomeLanguagesMatplotlib.artist.Artist.draw() in Python

Matplotlib.artist.Artist.draw() in Python

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:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6634 POSTS0 COMMENTS
Nicole Veronica
11801 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11863 POSTS0 COMMENTS
Shaida Kate Naidoo
6750 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6701 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS