Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (16.4k points)

Look at the following code, where I've used IPython.display:

from IPython.display import display, Image

display(Image(filename='MyImage.png'))

I also used matplotlib package with the following code:

import matplotlib.pyplot as plt

import matplotlib.image as mpimg

plt.imshow(mpimg.imread('MyImage.png'))

but I didn't get the image, Nothing is displayed. Does anyone help me?

1 Answer

0 votes
by (26.4k points)

Try the following code:

%pylab inline

import matplotlib.pyplot as plt

import matplotlib.image as mpimg

img = mpimg.imread('your_image.png')

imgplot = plt.imshow(img)

plt.show()

Interested to learn more about python? Come and join: python certification course

For more details, do check out..

Related questions

0 votes
1 answer
asked Nov 30, 2020 in Python by laddulakshana (16.4k points)
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...