Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module 'matplotlib' has no attribute 'imshow' [duplicate]

I am trying to display data as an image using matplotlib, but I received this error: AttributeError module 'matplotlib' has no attribute 'imshow'

Here is an example code:

import numpy as np
import matplotlib as plt 

im = np.arange(10)
im = im[np.newaxis, :]
im = np.repeat(im, 10, axis=0)
plt.imshow(im, cmap='gray')

using : python : 3.7.9 matplotlib: 3.3.4

like image 809
Najib Shakkour Avatar asked Aug 24 '26 22:08

Najib Shakkour


1 Answers

The import should be:

import matplotlib.pyplot as plt 
like image 83
tdy Avatar answered Aug 28 '26 21:08

tdy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!