dival.util.plot module

Provides utility functions for visualization.

dival.util.plot.plot_image(x, fig=None, ax=None, **kwargs)[source]

Plot image using matplotlib’s imshow() method.

Parameters
  • x (array-like or PIL image) – The image data. For further information see imshow documentation.

  • fig (matplotlib.figure.Figure, optional) – The figure to plot the image in. If fig is None, but ax is given, it is retrieved from ax. If both fig is None and ax is None, a new figure is created.

  • ax (matplotlib.axes.Axes, optional) – The axes to plot the image in. If None, an axes object is created in fig.

  • kwargs (dict, optional) – Keyword arguments passed to ax.imshow.

Returns

  • im (matplotlib.image.AxesImage) – The image that was plotted.

  • ax (matplotlib.axes.Axes) – The axes the image was plotted in.

dival.util.plot.plot_images(x_list, nrows=1, ncols=- 1, fig=None, vrange='equal', cbar='auto', rect=None, fig_size=None, **kwargs)[source]

Plot multiple images using matplotlib’s imshow() method in subplots.

Parameters
  • x_list (sequence of (array-like or PIL image)) –

    List of the image data. For further information see imshow documentation.

  • nrows (int, optional) – The number of subplot rows (the default is 1). If -1, it is computed by ceil(len(x_list)/ncols), or set to 1 if ncols is not given.

  • ncols (int, optional) – The number of subplot columns. If -1, it is computed by ceil(len(x_list)/nrows) (default). If both nrows and ncols are given, the value of ncols is ignored.

  • vrange ({'equal', 'individual'} or [list of ](float, float), optional) –

    Value ranges for the colors of the images. If a string is passed, the range is auto-computed:

    'equal'

    The same colors are used for all images.

    'individual'

    The colors differ between the images.

    If a tuple of floats is passed, it is used for all images. If a list of tuples of floats is passed, each tuple is used for one image.

  • cbar ({'one', 'many', 'auto', 'none'}, optional) – Colorbar option. If cbar=='one', one colorbar is shown. Only possible if the value ranges used for the colors (cf. vrange) are the same for all images. If cbar=='many', a colorbar is shown for every image. If cbar=='auto', either 'one' or 'many' is chosen, depending on whether vrange is equal for all images. If cbar=='none', no colorbars are shown.

  • fig (matplotlib.figure.Figure, optional) – The figure to plot the images in. If None, a new figure is created.

  • kwargs (dict, optional) – Keyword arguments passed to plot_image, which in turn passes them to imshow.

Returns

  • im (ndarray of matplotlib.image.AxesImage) – The images that were plotted.

  • ax (ndarray of matplotlib.axes.Axes) – The axes the images were plotted in.