본문 바로가기
파이썬

파이썬 How to set a single, main title above all the subplots with Pyplot?

by º기록 2020. 9. 28.
반응형

pyplot 을 사용하고 있습니다. 4 개의 서브 플롯이 있습니다. 모든 서브 플롯 위에 하나의 메인 제목을 설정하는 방법은 무엇입니까? title () 은 마지막 서브 플롯 위에 그것을 설정합니다.

 

해결 방법

 


import matplotlib.pyplot as plt
import numpy as np

fig=plt.figure()
data=np.arange(900).reshape((30,30))
for i in range(1,5):
    ax=fig.add_subplot(2,2,i)        
    ax.imshow(data)

fig.suptitle('Main title') # or plt.suptitle('Main title')
plt.show()

여기에 이미지 설명 입력

 

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

 

 

반응형

댓글