Matplotlib.axes.Axes.remove() en Python

Matplotlib es una biblioteca en Python y es una extensión matemática numérica para la biblioteca NumPy. La clase Axes contiene la mayoría de los elementos de la figura: Axis, Tick, Line2D, Text, Polygon, etc., y establece el sistema de coordenadas. Y las instancias de Axes admiten devoluciones de llamada a través de un atributo de devoluciones de llamada.

Función matplotlib.axes.Axes.remove()

La función Axes.remove() en el módulo de ejes de la biblioteca matplotlib se usa para eliminar al artista de la figura si es posible.

Sintaxis:

Axes.remove(self)

Los siguientes ejemplos ilustran la función matplotlib.axes.Axes.remove() en matplotlib.axes:

Ejemplo 1:

# Implementation of matplotlib function
import matplotlib.pyplot as plt
  
fig, axs = plt.subplots()
axs.plot([1, 2, 3])
axs.remove()
  
fig.suptitle('matplotlib.axes.Axes.remove()\
 function Example', fontweight ="bold")
  
plt.show()

Producción:

Ejemplo 2:

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

Producción:

Publicación traducida automáticamente

Artículo escrito por SHUBHAMSINGH10 y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *