Call Python from matlab, error related to Matplotlib.pyplot
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, everyone,
I am calling a Python script from Matlab, if the program included code likes 'import matplotlib.backends.qt_editor.figureoptions as figureoptions, or import matplotlib.pyplot as plt', an error 'Python Error: AttributeError: module 'matplotlib' has no attribute 'pyplot'' will was occured. Please help me to fin this problem, thank you.
import numpy
import skimage
import matplotlib.pyplot as plt
from skimage import io
from skimage.morphology import watershed
def imgread():
imgpath='D:/PROJECT/CoreModelingV1.2/Pore_Extr_Sim/Img4codeDev_S35'
imgtype='\*.png'
imgname=imgpath+imgtype
print('the file is: ',imgname)
img=skimage.io.imread_collection(imgname)
imdata=img.concatenate()
# imdata=imdata[:,300:500,300:500]
# imdata=imdata[:,380:480,300:400]
imdata=imdata==0
plt.figure(figsize=[10, 10])
plt.imshow(imdata[0], origin='upper')
plt.show()
return imdata
py.test5.imgread
the file is: D:/PROJECT/CoreModelingV1.2/Pore_Extr_Sim/Img4codeDev_S35\*.png
Error using test5>imgread (line 18)
Python Error: AttributeError: module 'matplotlib' has no attribute 'pyplot'
2 comentarios
Nithin
el 27 de Oct. de 2022
Hello,
This error seems to be a Python error and not a MATLAB one. Does the script throw the same error when executed through command line?
Al Danial
el 5 de Nov. de 2022
MATLAB and matplotlib both ship with Qt graphics libraries. Try changing matplotlib's graphics backend to a different library to avoid conflicts. Change
import matplotlib.pyplot as plt
to
import matplotlib
matplotlib.use('WXAgg')
import matplotlib.pyplot as plt
Respuestas (0)
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!