April 2018
Beginner to intermediate
300 pages
7h 34m
English
We will align the images in a grid of two rows and five columns. We first set the rectangular canvas by plt.figure(). For each sample image of a digit, we define the axes with the plt.subplot() function, and then call imshow() to show the arrays of color values as images. Recall that the colormap 'gray_r' plots values in grayscale from white to black with values from zero to maximum. As there is no need for x and y tick labels to show the scales, we will remove them by passing an empty list to plt.xticks() and plt.yticks() to remove the clutter. Here is the code snippet to do so:
import matplotlib.pyplot as pltnrows, ncols = 2, 5plt.figure(figsize=(6,3))for i in range(ncols * nrows): ax = plt.subplot(nrows, ...
Read now
Unlock full access