반응형
+matplotlib subplot 화면분할 grid로 분할하기
HTML의 테이블의 TR, TD, colspan, rowspan 하듯이 그리드로 서브 플롯을 구성할 수 있다.
예제)
import matplotlib.pyplot as plt
import numpy as np
plt.figure(figsize=(15,8))
plt.subplots_adjust(hspace=0.5, wspace=0.4)
gridshape=(4,3)
loc=(0,0)
plt.subplot2grid(gridshape, loc, colspan=2)
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
loc=(0,2)
plt.subplot2grid(gridshape, loc, rowspan=2)
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
loc=(1,0)
plt.subplot2grid(gridshape, loc)
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
loc=(1,1)
plt.subplot2grid(gridshape, loc )
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
loc=(2,0)
plt.subplot2grid(gridshape, loc)
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
loc=(2,1)
plt.subplot2grid(gridshape, loc)
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
loc=(2,2)
plt.subplot2grid(gridshape, loc)
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
loc=(3,0)
plt.subplot2grid(gridshape, loc, colspan=3)
plt.plot(np.arange(0,10,1), np.random.randint(0,10,10))
plt.show()
결과)
'Python' 카테고리의 다른 글
[Python] enum (0) | 2019.03.28 |
---|---|
랜덤스트링 만들기 (0) | 2019.03.22 |
File I/O, Directory list, read/write (0) | 2018.07.04 |
WebAPI thread work status (0) | 2018.07.03 |
Python BeautifulSoup 웹크롤링/HTML 파싱. (0) | 2018.04.25 |