How to apply pseudo color schemes to an image plot in Matplotlib?

Pseudocolor can be a useful tool for enhancing the contrast and visualizing your data more easily. This is especially useful when making presentations of your data using projectors(because their contrast is typically quite poor).

Pseudocolor is only relevant to single-channel, grayscale, luminosity images. We currently have an RGB image. Since R, G, and B are all similar, we can just pick one channel of our data−


  • Set the figure size and adjust the padding between and around the subplots.
  • Read an image from a file into an array.
  • Pick one channel of our data.
  • Display data as an image, i.e., on a 2D regular raster.
  • Turn off the axes.
  • To display the figure, use show() method.


from matplotlib import pyplot as plt, image as mimg
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

img = mimg.imread('bird.jpg')
lum_img = img[:, :, 0]