방법 1 - plt.subplots(행, 열, 크기)
- fig, (subplot1, 2, ...) = plt.subplots(행 수, 열 수, 크기)
- 한 번에 서브플랏을 정의하고 시작
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(15, 5))
ax1.hist(binomial_data, bins = 20, color = 'blue')
ax1.set_title('Binomial Distribution')
ax2.hist(uniform_data, bins = 20, color = 'green')
ax2.set_title('Uniform Distribution')
ax3.hist(normal_data, bins = 20, color = 'red')
ax3.set_title('Normal Distribution')
plt.show()
방법 2 - plt.subplot(행, 열, 그릴 위치) (추천)
- plt.subplot(행, 열, 지금 그릴 위치)
plt.figure(figsize=(15,5))
plt.subplot(1, 3, 1)
plt.hist(binomial_data, bins = 20, color = 'blue')
plt.subplot(1, 3, 2)
plt.hist(uniform_data, bins = 20, color = 'green')
plt.subplot(1, 3, 3)
plt.hist(normal_data, bins = 20, color = 'red')
plt.show()