How to Read and View Images in MatPlotLib



Reading images is a common recipe you will use in MatPlotLib. Reguarly in data science you will be building models based on images (this is very popular in machine learning). So, it would be helpful to display those images and MatPlotLib can help with this. In this article, we will see how to read and view images with MatPlotLib.

Working with Images

To read images with MatPlotLib, we use the imread method on pyplot. Then, to display the image, we use the imshow method. In this example, I have placed a picture of pikachu in the same directory as my code.

import matplotlib.pyplot as plt
image = plt.imread('pikachu.jpg')
GoTea - KoalaTea