Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Matplotlib.artist.Artist.remove() in Python

  • Last Updated : 15 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.remove() Method

The remove() method in artist module of matplotlib library is used to remove the artist from the figure if possible.

 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

Syntax: Artist.remove(self)



Parameters: This method does not accepts any parameter.

Returns: This method return the figure after removal of the artist.

Below examples illustrate the matplotlib.artist.Artist.remove() function in matplotlib:

Example 1:




# Implementation of matplotlib function
from matplotlib.artist import Artist
import matplotlib.pyplot as plt
  
  
fig, axs = plt.subplots()
axs.plot([1, 2, 3])
  
# use of remove() method
Artist.remove(axs)
  
fig.suptitle("""matplotlib.artist.Artist.remove()
function Example""", fontweight="bold")
  
plt.show()

Output:

Example 2:




# Implementation of matplotlib function
from matplotlib.artist import Artist 
import matplotlib.pyplot as plt 
    
    
fig, (axs, axs2) = plt.subplots(2, 1
gs = axs2.get_gridspec()  
  
# use of remove() method
Artist.remove(axs)
  
axbig = fig.add_subplot(gs[1:, -1]) 
axbig.annotate("Removed one Axes"
               (0.4, 0.5), 
               xycoords ='axes fraction'
               va ='center'
  
fig.suptitle("""matplotlib.artist.Artist.remove()
function Example""", fontweight="bold")
  
plt.show()

Output:




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!