Plotting
This module provides different plotting utilities that are commonly used in ML context such as plotting a grid of images or show a single image.
get_grid(n, nrows=None, ncols=None, title=None, weight='bold', size=14, **kwargs)
Return a grid of n axes, rows by cols. nrows and ncols are mutually
exclusive. This means you only need to pass one of them and the other will be
inferred.
Parameters:
-
n(int) –Number of axes.
-
nrows(int, default:None) –Number of rows, default=
int(math.sqrt(n)). -
ncols(int, default:None) –Number of columns, default=
ceil(n/rows). -
title(str, default:None) –Title of the Figure.
-
weight(str, default:'bold') –Title font weight.
-
size(int, default:14) –Title font size.
Returns:
-
fig(Figure) –Top level container for all axes.
-
ax(array of Axes) –Array of axes.
show_image(image, ax=None, figsize=None, title=None, noframe=True, **kwargs)
Show a PIL or PyTorch image on ax.
Parameters:
-
image(PIL image or array-like) –Image data.
-
ax(Axes, default:None) –Axes to plot the image on.
-
figsize(tuple, default:None) –Width, height in inches of the returned Figure
-
title(str, default:None) –Title of the image
-
noframe(bool, default:True) –Whether to remove axis from the plotted image.
Returns:
-
ax(AxesImage) –Plotted image on
ax.
show_images(images, nrows=None, ncols=None, titles=None, **kwargs)
Show all images as subplots with nrows x ncols using titles.
Parameters:
-
images(list or array - like) –List of images to show.
-
nrows(int, default:None) –Number of rows in the grid.
-
ncols(int, default:None) –Number of columns in the grid.
-
titles(list, default:None) –List of titles for each image.
subplots(nrows=1, ncols=1, figsize=None, imsize=3, suptitle=None, **kwargs)
A figure and set of subplots to display images of imsize inches.
Parameters:
-
nrows(int, default:1) –Number of rows in returned axes grid.
-
ncols(int, default:1) –Number of columns in returned axes grid.
-
figsize(tuple, default:None) –Width, height in inches of the returned Figure.
-
imsize(int, default:3) –Size (in inches) of images that will be displayed in the returned figure.
-
suptitle(str, default:None) –Title of the Figure.
Returns:
-
fig(Figure) –Top level container for all axes.
-
ax(array of Axes) –Array of axes.