본문 바로가기
파이썬

파이썬 matplotlib를 사용하여 이미지를 나란히 표시

by º기록 2020. 10. 24.
반응형

예를 들어 다음과 같이 matplotlib 를 사용하여 이미지를 나란히 그릴 수있는 방법이 궁금합니다.


내가 얻은 가장 가까운 것은 다음과 같습니다.


이것은 다음 코드를 사용하여 생성되었습니다.

f, axarr = plt.subplots(2,2)
axarr[0,0] = plt.imshow(image_datas[0])
axarr[0,1] = plt.imshow(image_datas[1])
axarr[1,0] = plt.imshow(image_datas[2])
axarr[1,1] = plt.imshow(image_datas[3])


 

해결 방법

 

직면 한 문제는 imshow 의 반환 ( matplotlib.image.AxesImage )을 기존 axes 객체에 할당 하려고한다는 것입니다.

axarr 의 다른 축에 이미지 데이터를 플로팅하는 올바른 방법은 다음과 같습니다.

f, axarr = plt.subplots(2,2)
axarr[0,0].imshow(image_datas[0])
axarr[0,1].imshow(image_datas[1])
axarr[1,0].imshow(image_datas[2])
axarr[1,1].imshow(image_datas[3])

개념은 모든 서브 플롯에 대해 동일하며 대부분의 경우 axes 인스턴스는 pyplot (plt) 인터페이스와 동일한 메서드를 제공합니다.


 

참조 페이지 https://stackoverflow.com/questions/41793931

 

 

반응형

댓글