Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Matplotlib.figure.Figure.figimage() in Python

  • Last Updated : 30 Apr, 2020

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The figure module provides the top-level Artist, the Figure, which contains all the plot elements. This module is used to control the default spacing of the subplots and top level container for all plot elements.

matplotlib.figure.Figure.figimage() function

The figimage() method of figure module of matplotlib library is used to add a non-resampled image to the figure.

Syntax: figimage(self, X, xo=0, yo=0, alpha=None, norm=None, cmap=None, vmin=None, vmax=None, origin=None, resize=False, **kwargs)

Parameters: This accept the following parameters that are described below:

  • X: This parameter is the image data.
  • xo, yo: These parameters are the x/y image offset in pixels.
  • alpha : This parameter is the alpha blending value.
  • norm : This parameter is the Normalize instance to map the luminance to the interval [0, 1].
  • cmap : This parameter is the colormap to use.
  • vmin, vmax: These parameter are the the data limits for the colormap.
  • origin : This parameter indicates where the [0, 0] index of the array is in the upper left or lower left corner of the axes.
  • resize : This parameter is used to resize the figure to match the given image size.

Returns: This method returns the matplotlib.image.FigureImage.

Below examples illustrate the matplotlib.figure.Figure.figimage() function in matplotlib.figure:

Example 1:

# Implementation of matplotlib function 
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
nx = int(fig.get_figwidth() * fig.dpi)
ny = int(fig.get_figheight() * fig.dpi)
data = np.random.random((ny, nx))
function Example', fontweight ="bold"


Example 2:

# Implementation of matplotlib function 
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
fig = plt.figure()
Z = np.arange(10000).reshape((100, 100))
Z[:, 50:] = 1
im1 = fig.figimage(Z, xo = 500, yo = 100,
                   origin ='lower')
im2 = fig.figimage(Z, xo = 100, yo = 100,
                   alpha =.6,
                   origin ='lower')
fig.suptitle('matplotlib.figure.Figure.figimage() \
function Example', fontweight ="bold"


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!