import matplotlib.pyplot as plt
w = 4
h = 3
d = 70
plt.figure(figsize=(w, h), dpi=d)
x = [[3, 4, 5],
[2, 3, 4],
[1, 2, 3]]
color_map = plt.imshow(x)
color_map.set_cmap("Blues_r")
plt.colorbar()
plt.savefig("out.png")
matplotlib.pyplot.imshow() Function:
The imshow() function in pyplot module of matplotlib library is used to display data as an image; i.e. on a 2D regular raster.
Syntax: matplotlib.pyplot.imshow(X, cmap=None, norm=None, aspect=None, interpolation=None, alpha=None, vmin=None, vmax=None, origin=None, extent=None, shape=, filternorm=1, filterrad=4.0, imlim=, resample=None, url=None, *, data=None, **kwargs)
Parameters: This method accept the following parameters that are described below:
X: This parameter is the data of the image.
cmap : This parameter is a colormap instance or registered colormap name.