Matplotlib

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
fig = plt.figure()
fig = plt.figure(figsize = (5,5), layout = 'constrained')
ax1 = fig.add_subplot(2, 2, 1)
ax2 = fig.add_subplot(2, 2, 2)
ax3 = fig.add_subplot(2, 2, 3)

# 출력 (빈 객체)
fig
# 1변량 trend
ax1.plot(np.random.standard_normal(50).cumsum(), color="black", linestyle="dashed")

# Histogram
ax2.hist(np.random.standard_normal(100), bins=20, color="black", alpha=0.3)

# Satter Plot (산점도)
ax3.scatter(np.arange(30), np.arange(30) + 3 * np.random.standard_normal(30))

# 출력
fig
fig, axes = plt.subplots(2, 2)
axes[0,0].plot(np.random.standard_normal(50).cumsum(), 
               color="black", 
               linestyle="dashed")

axes[0,1].hist(np.random.standard_normal(100), 
               bins=20, 
               color="black", 
               alpha=0.3)
               
axes[1,0].scatter(np.arange(30), 
                  np.arange(30) + 3 * np.random.standard_normal(30))

axes
인수 설명
nrows Integer - 서브플롯의 행 수
ncols Integer - 서브플롯의 열 수
sharex Logical - 모든 서브플롯이 동일한 x축을 사용할 것인가 여부
sharey Logical - 모든 서브플롯이 동일한 축y을 사용할 것인가 여부

그림의 종류

M.1. 관계의 표현: $y = f(x)$