I don't understand the python syntax where you can have mutliple variable names before the assignment. The line I am referring to is a, ax = plt.subplots(2, 2)
. Eventhough a
is never mentioned ever again, the code doesn't work when I delete a
. Does the subplots
function somehow refer to a
and why is it important?
from skimage.io import imread
import matplotlib.pyplot as plt
# Original
img = imread('catG.png')
# Invert
img_inv = 255 - img
# Mirrored
img_mirr = img[:,::-1]
# Crop
img_cat = img[30:280,200:550]
plt.close('all')
a, ax = plt.subplots(2, 2)
ax[0, 0].imshow(img, cmap='Greys_r')
ax[0, 0].set_title('Original')
ax[0, 1].imshow(img_inv, cmap='Greys_r')
ax[0, 1].set_title('Inverted')
ax[1, 0].imshow(img_mirr, cmap='Greys_r')
ax[1, 0].set_title('Mirrored')
ax[1, 1].imshow(img_cat, cmap='Greys_r')
ax[1, 1].set_title('Cropped')
plt.show()