import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots() im = plt.imread('image.png') ax.imshow(im) plt.show()
import matplotlib.pyplot as plt import numpy as np fig, ax = plt.subplots() im = np.random.rand(50,50) ax.imshow(im) plt.show()This code creates a random 50x50 matrix and displays it as an image using figimage. The package library used in these examples is matplotlib.figure.