Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Matplotlib.artist.Artist.draw() in Python

  • Last Updated : 10 May, 2020

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

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!