Display

Back to Scenes

Displays ndarrays as images, but is easier to use and more flexible than matplotlib’s imshow.

display(*imgs, **kwargs)[source]

Display 2D and 3D ndarrays as images with matplotlib.

The ndarrays must either be 2D, or 3D with 1 or 3 bands. If they are 3D masked arrays, the mask will be used as an alpha channel.

Unlike matplotlib’s imshow, arrays can be any dtype; internally, each is normalized to the range [0..1].

Parameters:
  • *imgs (1 or more ndarrays) – When multiple images are given, each is displayed on its own row.
  • bands_axis (int, default 0) – Axis which contains bands in each array.
  • title (str, or sequence of str; optional) – Title for each image. If a sequence, must be the same length as imgs.
  • size (int, default 10) – Length, in inches, to display the longer side of each image.
  • robust (bool, default True) – Use the 2nd and 98th percentiles to compute color limits. Otherwise, the minimum and maximum values in each array are used.
  • interpolation (str, default "bilinear") –

    Interpolation method for matplotlib to use when scaling images for display.

    Bilinear is the default, since it produces smoother results when scaling down continuously-valued data (i.e. images). For displaying discrete data, however, choose ‘nearest’ to prevent values not existing in the input from appearing in the output.

    Acceptable values are ‘none’, ‘nearest’, ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’, ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’, ‘mitchell’, ‘sinc’, ‘lanczos’

  • colormap (str, default None) –

    The name of a Colormap registered with matplotlib. Some commonly used built-in options are ‘plasma’, ‘magma’, ‘viridis’, ‘inferno’. See https://matplotlib.org/users/colormaps.html for more options.

    To use a Colormap, the input images must have a single band. The Colormap will be ignored for images with more than one band.

Example

In [1]: import descarteslabs as dl

In [2]: import numpy as np

In [3]: a = np.arange(20*15).reshape((20, 15))

In [4]: b = np.tan(a)

In [5]: dl.scenes.display(a, b, size=4)
https://cdn.descarteslabs.com/docs/_images/display.png
Raises:ImportError – If matplotlib is not installed.