본문 바로가기
프로그램

[파이썬] 문제 : subplot의 크기 설정

by 오디세이99 2023. 3. 15.
728x90
반응형
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import gridspec

x = np.arange(0, 10, 0.2)
y = np.sin(x)

fig = plt.figure(figsize=(10, 8))
# GridSpec를 사용해서 subplot 각각의 크기를 설정
gs = gridspec.GridSpec(nrows=3, # row 몇 개 
                       ncols=1, # col 몇 개 
                       height_ratios=[3, 1, 1], 
                       width_ratios=[6]
                      )
ax0 = plt.subplot(gs[0])
ax0.plot(x, y)
ax1 = plt.subplot(gs[1])
ax1.plot(y, x)
ax1 = plt.subplot(gs[2])
ax1.plot(y, x)

plt.show()

728x90
반응형

댓글