Matplotlib.figure.Figure.get_figwidth() en Python

Matplotlib es una biblioteca en Python y es una extensión matemática numérica para la biblioteca NumPy. El módulo de figura proporciona el artista de nivel superior, la figura, que contiene todos los elementos de la trama. Este módulo se utiliza para controlar el espaciado predeterminado de las subparcelas y el contenedor de nivel superior para todos los elementos de la parcela.

método matplotlib.figure.Figure.get_figwidth()

El módulo de figura del método get_figwidth() de la biblioteca matplotlib se usa para obtener el ancho de la figura como un flotador.

Sintaxis: get_figwidth(self)

Parámetros: este método no acepta ningún parámetro.

Devoluciones: este método devuelve el ancho de la figura como un flotador.

Los siguientes ejemplos ilustran la función matplotlib.figure.Figure.get_figwidth() en matplotlib.figure:

Ejemplo 1:

# Implementation of matplotlib function 
import matplotlib.pyplot as plt 
from matplotlib.figure import Figure
from mpl_toolkits.axisartist.axislines import Subplot 
import numpy as np 
  
  
fig = plt.figure() 
      
ax = Subplot(fig, 111) 
fig.add_subplot(ax)  
  
w = fig.get_figwidth()
ax.text(0.2, 0.5, 
        "Value Return by get_figwidth() : "
        + str(w),
        fontweight ="bold")
    
fig.canvas.draw()
fig.suptitle('matplotlib.figure.Figure.get_figwidth() \
function Example', fontweight ="bold") 
  
plt.show()

Producción:

get_figwidth-matplotlib

Ejemplo 2:

# Implementation of matplotlib function 
import matplotlib.pyplot as plt 
from matplotlib.figure import Figure
import numpy as np 
  
  
fig = plt.figure(edgecolor = "red", figsize =(7, 6)) 
       
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])
     
xx = np.arange(0, 2 * np.pi, 0.01) 
ax.plot(xx, np.sin(xx)) 
   
w = fig.get_figwidth()
ax.text(1.5, 0,
        "Value Return by get_figwidth() : "
        + str(w),
        fontweight ="bold")
     
fig.canvas.draw()
fig.suptitle('matplotlib.figure.Figure.get_figwidth() \
function Example', fontweight ="bold") 
  
plt.show()

Producción:

get_figwidth-python-2

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 *