plt.subplot(행열순서)

# 2행 2열 그래프

# 그래프 변수 설정

fig = plt.figure()

# x 데이터

names = ['group_a', 'group_b', 'group_c']
values1 = [1, 10, 100]
values2 = [100, 50, 10]
values3 = [100, 40, 100]
values4 = [80, 40, 100]

plt.subplot(221) # 2행 2열 첫번째
plt.plot(names, values1)

plt.subplot(222) # 2행 2열 두번째
plt.plot(names, values2)

plt.subplot(223) # 2행 2열 세번째
plt.plot(names, values3)

plt.subplot(224) # 2행 2열 네번째
plt.plot(names, values4)

plt.show()

Untitled

# 3행 1열 그래프
# 그래프 변수 설정
fig = plt.figure()

# x 데이터
names = ['group_a', 'group_b', 'group_c']
values1 = [1, 10, 100]
values2 = [100, 50, 10]
values3 = [100, 40, 100]
# values4 = [80, 40, 100]

plt.figure(figsize=(9,10))
plt.subplot(311) # 3행 1열 첫번째
plt.plot(names, values1)

plt.subplot(312) # 3행 1열 두번째
plt.plot(names, values2)

plt.subplot(313) # 3행 1열 세번째
plt.plot(names, values3)

plt.show()

Untitled

# 1행 3열 그래프
# 그래프 변수 설정
fig = plt.figure()

# x 데이터
names = ['group_a', 'group_b', 'group_c']
values1 = [1, 10, 100]
values2 = [100, 50, 10]
values3 = [100, 40, 100]
# values4 = [80, 40, 100]

plt.figure(figsize=(15,5))
plt.subplot(131) # 1행 3열 첫번째
plt.plot(names, values1)

plt.subplot(132) # 1행 3열 두번째
plt.plot(names, values2)

plt.subplot(133) # 1행 3열 세번째
plt.plot(names, values3)

plt.show()

Untitled