Quarto 레이아웃 포괄적 테스트

1. 기본 레이아웃 테스트

1.1 단일 컬럼 레이아웃

기본적인 단일 컬럼 레이아웃입니다. 이 섹션은 전체 너비를 사용합니다.

import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10, 100)
y = np.sin(x)

plt.figure(figsize=(10, 4))
plt.plot(x, y)
plt.title('기본 플롯')
plt.xlabel('X축')
plt.ylabel('Y축')
plt.grid(True)
plt.show()
/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 52629 (\N{HANGUL SYLLABLE CUG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44592 (\N{HANGUL SYLLABLE GI}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48376 (\N{HANGUL SYLLABLE BON}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54540 (\N{HANGUL SYLLABLE PEUL}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 47215 (\N{HANGUL SYLLABLE ROS}) missing from font(s) DejaVu Sans.

1.2 다중 컬럼 레이아웃

import pandas as pd

data = {
    '이름': ['김철수', '이영희', '박민수'],
    '나이': [25, 30, 28],
    '점수': [85, 92, 88]
}
df = pd.DataFrame(data)
print(df)
plt.figure(figsize=(5, 4))
plt.bar(df['이름'], df['점수'], color='skyblue')
plt.title('점수 분포')
plt.ylabel('점수')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()

왼쪽 컬럼

이것은 왼쪽 컬럼의 내용입니다. 두 개의 컬럼으로 나뉘어 표시됩니다.

    이름  나이  점수
0  김철수  25  85
1  이영희  30  92
2  박민수  28  88

오른쪽 컬럼

이것은 오른쪽 컬럼의 내용입니다. 같은 행에 나란히 배치됩니다.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 44608 (\N{HANGUL SYLLABLE GIM}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 52384 (\N{HANGUL SYLLABLE CEOL}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 49688 (\N{HANGUL SYLLABLE SU}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 51060 (\N{HANGUL SYLLABLE I}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 50689 (\N{HANGUL SYLLABLE YEONG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 55148 (\N{HANGUL SYLLABLE HYI}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 48149 (\N{HANGUL SYLLABLE BAG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 48124 (\N{HANGUL SYLLABLE MIN}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 51216 (\N{HANGUL SYLLABLE JEOM}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 48516 (\N{HANGUL SYLLABLE BUN}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/2535598623.py:6: UserWarning:

Glyph 54252 (\N{HANGUL SYLLABLE PO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51216 (\N{HANGUL SYLLABLE JEOM}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49688 (\N{HANGUL SYLLABLE SU}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48516 (\N{HANGUL SYLLABLE BUN}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54252 (\N{HANGUL SYLLABLE PO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44608 (\N{HANGUL SYLLABLE GIM}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 52384 (\N{HANGUL SYLLABLE CEOL}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51060 (\N{HANGUL SYLLABLE I}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 50689 (\N{HANGUL SYLLABLE YEONG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 55148 (\N{HANGUL SYLLABLE HYI}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48149 (\N{HANGUL SYLLABLE BAG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48124 (\N{HANGUL SYLLABLE MIN}) missing from font(s) DejaVu Sans.

2. 고급 레이아웃 구성

2.1 사용자 정의 비율 레이아웃

작은 영역

작은 영역 (1/3)

큰 영역

큰 영역 (2/3)

전체 너비 영역

이 영역은 전체 너비를 사용합니다.

2.2 3열 레이아웃

열 1

첫 번째 열의 내용

열 2

두 번째 열의 내용

열 3

세 번째 열의 내용

2.3 복잡한 중첩 레이아웃

import seaborn as sns

# 데이터 생성
np.random.seed(42)
data = np.random.randn(100)

plt.figure(figsize=(10, 3))
plt.hist(data, bins=30, color='coral', alpha=0.7)
plt.title('히스토그램 - 전체 너비')
plt.xlabel('값')
plt.ylabel('빈도')
plt.show()
plt.figure(figsize=(5, 4))
plt.scatter(np.random.rand(50), np.random.rand(50), c='green', alpha=0.5)
plt.title('산점도 1')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()
plt.figure(figsize=(5, 4))
plt.scatter(np.random.rand(50), np.random.rand(50), c='purple', alpha=0.5)
plt.title('산점도 2')
plt.xlabel('X')
plt.ylabel('Y')
plt.show()

상단 전체 너비

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48712 (\N{HANGUL SYLLABLE BIN}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 46020 (\N{HANGUL SYLLABLE DO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 55176 (\N{HANGUL SYLLABLE HI}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49828 (\N{HANGUL SYLLABLE SEU}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 53664 (\N{HANGUL SYLLABLE TO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44536 (\N{HANGUL SYLLABLE GEU}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 47016 (\N{HANGUL SYLLABLE RAEM}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51204 (\N{HANGUL SYLLABLE JEON}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 52404 (\N{HANGUL SYLLABLE CE}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 45320 (\N{HANGUL SYLLABLE NEO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48708 (\N{HANGUL SYLLABLE BI}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44050 (\N{HANGUL SYLLABLE GABS}) missing from font(s) DejaVu Sans.

좌측 하단

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49328 (\N{HANGUL SYLLABLE SAN}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51216 (\N{HANGUL SYLLABLE JEOM}) missing from font(s) DejaVu Sans.

우측 하단

하단 전체 너비

이것은 하단 전체 너비 섹션입니다.

3. 그림 레이아웃 테스트

3.1 나란히 배치된 그림

plt.figure(figsize=(5, 4))
x = np.linspace(0, 2*np.pi, 100)
plt.plot(x, np.sin(x), 'b-', label='sin(x)')
plt.legend()
plt.title('사인 함수')
plt.grid(True)
plt.show()
plt.figure(figsize=(5, 4))
plt.plot(x, np.cos(x), 'r-', label='cos(x)')
plt.legend()
plt.title('코사인 함수')
plt.grid(True)
plt.show()
/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49324 (\N{HANGUL SYLLABLE SA}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51064 (\N{HANGUL SYLLABLE IN}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54632 (\N{HANGUL SYLLABLE HAM}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49688 (\N{HANGUL SYLLABLE SU}) missing from font(s) DejaVu Sans.

왼쪽 그림
/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 53076 (\N{HANGUL SYLLABLE KO}) missing from font(s) DejaVu Sans.

오른쪽 그림

3.2 다양한 크기의 그림

plt.figure(figsize=(8, 4))
t = np.linspace(0, 10, 1000)
signal = np.sin(2*np.pi*t) + 0.5*np.sin(4*np.pi*t)
plt.plot(t, signal, 'navy')
plt.title('복합 신호')
plt.xlabel('시간')
plt.ylabel('진폭')
plt.grid(True, alpha=0.3)
plt.show()
plt.figure(figsize=(4, 4))
sizes = [30, 25, 20, 15, 10]
labels = ['A', 'B', 'C', 'D', 'E']
plt.pie(sizes, labels=labels, autopct='%1.1f%%')
plt.title('파이 차트')
plt.show()
/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51652 (\N{HANGUL SYLLABLE JIN}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54253 (\N{HANGUL SYLLABLE POG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48373 (\N{HANGUL SYLLABLE BOG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54633 (\N{HANGUL SYLLABLE HAB}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49888 (\N{HANGUL SYLLABLE SIN}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54840 (\N{HANGUL SYLLABLE HO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49884 (\N{HANGUL SYLLABLE SI}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44036 (\N{HANGUL SYLLABLE GAN}) missing from font(s) DejaVu Sans.

큰 그림 (2/3 너비)
/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54028 (\N{HANGUL SYLLABLE PA}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51060 (\N{HANGUL SYLLABLE I}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 52264 (\N{HANGUL SYLLABLE CA}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 53944 (\N{HANGUL SYLLABLE TEU}) missing from font(s) DejaVu Sans.

작은 그림 (1/3 너비)

4. 특수 레이아웃 기능

4.1 사이드바 레이아웃

여백 주석

이것은 여백에 표시되는 내용입니다. 추가 정보나 주석을 제공할 수 있습니다.

본문 내용이 여기에 표시되며, 오른쪽 여백에 추가 정보가 나타납니다.

4.2 전체 화면 너비 사용

fig, axes = plt.subplots(1, 4, figsize=(16, 4))

for i, ax in enumerate(axes):
    x = np.linspace(0, 10, 100)
    y = np.sin(x + i)
    ax.plot(x, y)
    ax.set_title(f'서브플롯 {i+1}')
    ax.grid(True, alpha=0.3)

plt.tight_layout()
plt.show()
/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/3497814661.py:10: UserWarning:

Glyph 49436 (\N{HANGUL SYLLABLE SEO}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/3497814661.py:10: UserWarning:

Glyph 48652 (\N{HANGUL SYLLABLE BEU}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/3497814661.py:10: UserWarning:

Glyph 54540 (\N{HANGUL SYLLABLE PEUL}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/3497814661.py:10: UserWarning:

Glyph 47215 (\N{HANGUL SYLLABLE ROS}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49436 (\N{HANGUL SYLLABLE SEO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48652 (\N{HANGUL SYLLABLE BEU}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54540 (\N{HANGUL SYLLABLE PEUL}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 47215 (\N{HANGUL SYLLABLE ROS}) missing from font(s) DejaVu Sans.

페이지 전체 너비 그림

4.3 화면 전체 확장

이 섹션은 화면 전체 너비를 사용합니다. 매우 넓은 표나 시각화에 유용합니다.

항목1 항목2 항목3 항목4 항목5 항목6 항목7 항목8 항목9 항목10
A B C D E F G H I J
1 2 3 4 5 6 7 8 9 10
α β γ δ ε ζ η θ ι κ

5. 패널 레이아웃

5.1 탭셋 레이아웃

def fibonacci(n):
    """피보나치 수열 생성"""
    if n <= 1:
        return n
    else:
        return fibonacci(n-1) + fibonacci(n-2)

# 처음 10개 출력
fib_numbers = [fibonacci(i) for i in range(10)]
print("피보나치 수열:", fib_numbers)
피보나치 수열: [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
plt.figure(figsize=(10, 4))
plt.plot(range(10), fib_numbers, marker='o', linestyle='-', color='darkgreen')
plt.title('피보나치 수열 시각화')
plt.xlabel('인덱스')
plt.ylabel('값')
plt.grid(True, alpha=0.3)
plt.show()
/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54588 (\N{HANGUL SYLLABLE PI}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48372 (\N{HANGUL SYLLABLE BO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 45208 (\N{HANGUL SYLLABLE NA}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 52824 (\N{HANGUL SYLLABLE CI}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 50676 (\N{HANGUL SYLLABLE YEOL}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44033 (\N{HANGUL SYLLABLE GAG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54868 (\N{HANGUL SYLLABLE HWA}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 45937 (\N{HANGUL SYLLABLE DEG}) missing from font(s) DejaVu Sans.

피보나치 수열은 각 항이 앞의 두 항의 합인 수열입니다. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …

5.2 접을 수 있는 섹션

이것은 접을 수 있는 콜아웃 박스입니다. 클릭하면 내용이 표시됩니다.

# 간단한 통계 계산
data = np.random.normal(100, 15, 1000)
print(f"평균: {np.mean(data):.2f}")
print(f"표준편차: {np.std(data):.2f}")
print(f"최솟값: {np.min(data):.2f}")
print(f"최댓값: {np.max(data):.2f}")
평균: 100.70
표준편차: 14.89
최솟값: 51.38
최댓값: 146.18

6. 반응형 레이아웃

6.1 조건부 레이아웃

셀 1

내용 1

셀 2

내용 2

셀 3

내용 3

셀 4

내용 4

6.2 복합 그리드

plt.figure(figsize=(3, 3))
plt.plot([1,2,3], [1,4,9], 'ro-')
plt.title('그림 1')
plt.show()
plt.figure(figsize=(3, 3))
plt.plot([1,2,3], [1,2,3], 'bs-')
plt.title('그림 2')
plt.show()
plt.figure(figsize=(3, 3))
plt.plot([1,2,3], [3,2,1], 'g^-')
plt.title('그림 3')
plt.show()
fig, ax = plt.subplots(figsize=(10, 4))
ax.plot([1,2,3], [1,4,9], 'ro-', label='데이터 1')
ax.plot([1,2,3], [1,2,3], 'bs-', label='데이터 2')
ax.plot([1,2,3], [3,2,1], 'g^-', label='데이터 3')
ax.set_title('세 데이터셋 비교')
ax.legend()
ax.grid(True, alpha=0.3)
plt.show()
/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 47548 (\N{HANGUL SYLLABLE RIM}) missing from font(s) DejaVu Sans.

그림 1

그림 2

그림 3

하단 전체 너비 요약

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49464 (\N{HANGUL SYLLABLE SE}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 45936 (\N{HANGUL SYLLABLE DE}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 53552 (\N{HANGUL SYLLABLE TEO}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49483 (\N{HANGUL SYLLABLE SES}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44368 (\N{HANGUL SYLLABLE GYO}) missing from font(s) DejaVu Sans.

종합 비교

7. 테이블 레이아웃 테스트

7.1 기본 마크다운 테이블

이름 나이 직업 거주지
김철수 28 개발자 서울
이영희 32 디자이너 부산
박민수 25 기획자 대전
최지현 30 마케터 인천

7.2 정렬된 테이블

왼쪽 정렬 가운데 정렬 오른쪽 정렬 숫자
텍스트 A 텍스트 B 텍스트 C 100
긴 텍스트 항목 중간 짧음 1,234
Short Medium Length Very Long Text 56.78

7.3 Pandas 데이터프레임 테이블

import pandas as pd
import numpy as np

# 샘플 데이터 생성
np.random.seed(42)
df_sales = pd.DataFrame({
    '제품': ['노트북', '마우스', '키보드', '모니터', '헤드셋'],
    '1월': np.random.randint(100, 500, 5),
    '2월': np.random.randint(100, 500, 5),
    '3월': np.random.randint(100, 500, 5),
    '합계': [0] * 5
})
df_sales['합계'] = df_sales[['1월', '2월', '3월']].sum(axis=1)

print(df_sales.to_markdown(index=False))
| 제품   |   1월 |   2월 |   3월 |   합계 |
|:-------|------:|------:|------:|-------:|
| 노트북 |   202 |   288 |   430 |    920 |
| 마우스 |   448 |   120 |   187 |    755 |
| 키보드 |   370 |   202 |   472 |   1044 |
| 모니터 |   206 |   221 |   199 |    626 |
| 헤드셋 |   171 |   314 |   459 |    944 |

7.4 다중 컬럼 테이블 배치

왼쪽 테이블

과목 점수
국어 85
영어 92
수학 78

오른쪽 테이블

요일 온도(°C)
15
18
20

7.5 복잡한 Pandas 테이블

# 더 복잡한 데이터프레임
df_complex = pd.DataFrame({
    '지역': ['서울', '경기', '인천', '부산', '대구'],
    '인구(만명)': [967, 1356, 296, 339, 242],
    '면적(km²)': [605, 10171, 1063, 770, 884],
    'GDP(조원)': [418, 529, 79, 92, 60]
})

# 인구 밀도 계산
df_complex['인구밀도'] = (df_complex['인구(만명)'] * 10000 / df_complex['면적(km²)']).round(1)

# 1인당 GDP 계산 (백만원)
df_complex['1인당GDP'] = (df_complex['GDP(조원)'] * 1000 / df_complex['인구(만명)']).round(2)

print(df_complex.to_markdown(index=False))
| 지역   |   인구(만명) |   면적(km²) |   GDP(조원) |   인구밀도 |   1인당GDP |
|:-------|-------------:|------------:|------------:|-----------:|-----------:|
| 서울   |          967 |         605 |         418 |    15983.5 |     432.26 |
| 경기   |         1356 |       10171 |         529 |     1333.2 |     390.12 |
| 인천   |          296 |        1063 |          79 |     2784.6 |     266.89 |
| 부산   |          339 |         770 |          92 |     4402.6 |     271.39 |
| 대구   |          242 |         884 |          60 |     2737.6 |     247.93 |

7.6 스타일이 적용된 테이블

# 조건부 서식이 적용된 데이터프레임 생성
df_scores = pd.DataFrame({
    '학생': ['김A', '이B', '박C', '최D', '정E'],
    '국어': [85, 92, 78, 88, 95],
    '영어': [90, 85, 92, 78, 88],
    '수학': [88, 90, 85, 92, 82],
    '과학': [92, 88, 90, 85, 90]
})

df_scores['평균'] = df_scores[['국어', '영어', '수학', '과학']].mean(axis=1).round(1)
df_scores['등급'] = pd.cut(df_scores['평균'], 
                          bins=[0, 70, 80, 90, 100], 
                          labels=['D', 'C', 'B', 'A'])

print(df_scores.to_markdown(index=False))
| 학생   |   국어 |   영어 |   수학 |   과학 |   평균 | 등급   |
|:-------|-------:|-------:|-------:|-------:|-------:|:-------|
| 김A    |     85 |     90 |     88 |     92 |   88.8 | B      |
| 이B    |     92 |     85 |     90 |     88 |   88.8 | B      |
| 박C    |     78 |     92 |     85 |     90 |   86.2 | B      |
| 최D    |     88 |     78 |     92 |     85 |   85.8 | B      |
| 정E    |     95 |     88 |     82 |     90 |   88.8 | B      |

7.7 전체 너비 테이블

# 넓은 테이블 생성
df_wide = pd.DataFrame({
    '항목': ['제품A', '제품B', '제품C', '제품D', '제품E'],
    '1월': np.random.randint(1000, 5000, 5),
    '2월': np.random.randint(1000, 5000, 5),
    '3월': np.random.randint(1000, 5000, 5),
    '4월': np.random.randint(1000, 5000, 5),
    '5월': np.random.randint(1000, 5000, 5),
    '6월': np.random.randint(1000, 5000, 5),
    '7월': np.random.randint(1000, 5000, 5),
    '8월': np.random.randint(1000, 5000, 5),
    '9월': np.random.randint(1000, 5000, 5),
    '10월': np.random.randint(1000, 5000, 5),
    '11월': np.random.randint(1000, 5000, 5),
    '12월': np.random.randint(1000, 5000, 5),
})

df_wide['연간합계'] = df_wide.iloc[:, 1:].sum(axis=1)
print(df_wide.to_markdown(index=False))
| 항목   |   1월 |   2월 |   3월 |   4월 |   5월 |   6월 |   7월 |   8월 |   9월 |   10월 |   11월 |   12월 |   연간합계 |
|:-------|------:|------:|------:|------:|------:|------:|------:|------:|------:|-------:|-------:|-------:|-----------:|
| 제품A  |  4735 |  3391 |  2215 |  4385 |  4632 |  3047 |  1189 |  2899 |  4202 |   3888 |   3363 |   4417 |      42363 |
| 제품B  |  1130 |  2515 |  1955 |  1021 |  1474 |  4547 |  4005 |  4638 |  4556 |   3214 |   3061 |   3612 |      35728 |
| 제품C  |  2685 |  4485 |  3324 |  3300 |  2082 |  3747 |  3734 |  2267 |  4890 |   2297 |   1241 |   3945 |      37997 |
| 제품D  |  4380 |  3853 |  2184 |  1747 |  3558 |  1975 |  4005 |  3879 |  1646 |   3435 |   3041 |   2363 |      36066 |
| 제품E  |  1769 |  3433 |  1459 |  3904 |  4753 |  2806 |  1562 |  2528 |  3068 |   1600 |   3824 |   3139 |      33845 |

7.8 화면 전체 너비 테이블

# 매우 넓은 테이블
months = ['1월', '2월', '3월', '4월', '5월', '6월', '7월', '8월', '9월', '10월', '11월', '12월']
df_full = pd.DataFrame({
    '제품명': ['노트북 Pro 15"', '무선마우스 MX3', '기계식키보드 RGB', '27" 모니터 4K', 'USB-C 허브'],
})

for month in months:
    df_full[month] = np.random.randint(50, 200, 5)

df_full['Q1'] = df_full[['1월', '2월', '3월']].sum(axis=1)
df_full['Q2'] = df_full[['4월', '5월', '6월']].sum(axis=1)
df_full['Q3'] = df_full[['7월', '8월', '9월']].sum(axis=1)
df_full['Q4'] = df_full[['10월', '11월', '12월']].sum(axis=1)
df_full['연간총계'] = df_full[['Q1', 'Q2', 'Q3', 'Q4']].sum(axis=1)

print(df_full.to_markdown(index=False))
| 제품명           |   1월 |   2월 |   3월 |   4월 |   5월 |   6월 |   7월 |   8월 |   9월 |   10월 |   11월 |   12월 |   Q1 |   Q2 |   Q3 |   Q4 |   연간총계 |
|:-----------------|------:|------:|------:|------:|------:|------:|------:|------:|------:|-------:|-------:|-------:|-----:|-----:|-----:|-----:|-----------:|
| 노트북 Pro 15"   |   160 |   153 |   155 |    63 |   131 |    90 |   120 |   112 |   172 |    121 |     86 |    180 |  468 |  284 |  404 |  387 |       1543 |
| 무선마우스 MX3   |    57 |   181 |    53 |   144 |   160 |    64 |    58 |   188 |    54 |     61 |    148 |     50 |  291 |  368 |  300 |  259 |       1218 |
| 기계식키보드 RGB |    84 |    51 |   103 |    97 |   102 |    94 |   137 |   130 |    90 |     82 |    153 |     54 |  238 |  293 |  357 |  289 |       1177 |
| 27" 모니터 4K    |   130 |   183 |   195 |    64 |    73 |   114 |   178 |   185 |    77 |     97 |     84 |    191 |  508 |  251 |  440 |  372 |       1571 |
| USB-C 허브       |    99 |   103 |    93 |    89 |   173 |   138 |   185 |    82 |   184 |    111 |    150 |    152 |  295 |  400 |  451 |  413 |       1559 |

7.9 테이블과 그래프 조합

# 요약 통계 테이블
summary_data = pd.DataFrame({
    '지표': ['평균', '중앙값', '표준편차', '최솟값', '최댓값'],
    '값': [
        df_scores['평균'].mean(),
        df_scores['평균'].median(),
        df_scores['평균'].std(),
        df_scores['평균'].min(),
        df_scores['평균'].max()
    ]
})
summary_data['값'] = summary_data['값'].round(2)
print(summary_data.to_markdown(index=False))
plt.figure(figsize=(6, 4))
plt.barh(df_scores['학생'], df_scores['평균'], color='steelblue')
plt.xlabel('평균 점수')
plt.ylabel('학생')
plt.title('학생별 평균 성적')
plt.xlim(0, 100)
plt.grid(axis='x', alpha=0.3)
plt.tight_layout()
plt.show()
지표
평균 87.68
중앙값 88.8
표준편차 1.54
최솟값 85.8
최댓값 88.8
/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 54217 (\N{HANGUL SYLLABLE PYEONG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 44512 (\N{HANGUL SYLLABLE GYUN}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 51216 (\N{HANGUL SYLLABLE JEOM}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 49688 (\N{HANGUL SYLLABLE SU}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 44608 (\N{HANGUL SYLLABLE GIM}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 51060 (\N{HANGUL SYLLABLE I}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 48149 (\N{HANGUL SYLLABLE BAG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 52572 (\N{HANGUL SYLLABLE COE}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 51221 (\N{HANGUL SYLLABLE JEONG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 54617 (\N{HANGUL SYLLABLE HAG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 49373 (\N{HANGUL SYLLABLE SAENG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 48324 (\N{HANGUL SYLLABLE BYEOL}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 49457 (\N{HANGUL SYLLABLE SEONG}) missing from font(s) DejaVu Sans.

/var/folders/jn/3rrg7fh55wxd_bp4_48xj9f40000gn/T/ipykernel_65698/4194121316.py:8: UserWarning:

Glyph 51201 (\N{HANGUL SYLLABLE JEOG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44608 (\N{HANGUL SYLLABLE GIM}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51060 (\N{HANGUL SYLLABLE I}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48149 (\N{HANGUL SYLLABLE BAG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 52572 (\N{HANGUL SYLLABLE COE}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51221 (\N{HANGUL SYLLABLE JEONG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54617 (\N{HANGUL SYLLABLE HAG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49373 (\N{HANGUL SYLLABLE SAENG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 48324 (\N{HANGUL SYLLABLE BYEOL}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 54217 (\N{HANGUL SYLLABLE PYEONG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 44512 (\N{HANGUL SYLLABLE GYUN}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49457 (\N{HANGUL SYLLABLE SEONG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51201 (\N{HANGUL SYLLABLE JEOG}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 51216 (\N{HANGUL SYLLABLE JEOM}) missing from font(s) DejaVu Sans.

/Users/itaeyeon/Library/Python/3.9/lib/python/site-packages/IPython/core/pylabtools.py:152: UserWarning:

Glyph 49688 (\N{HANGUL SYLLABLE SU}) missing from font(s) DejaVu Sans.

학생별 평균 점수

7.10 피벗 테이블

# 피벗 테이블 예제
np.random.seed(123)
sales_data = pd.DataFrame({
    '지역': ['서울', '서울', '부산', '부산', '대구', '대구'] * 4,
    '분기': ['Q1', 'Q2', 'Q1', 'Q2', 'Q1', 'Q2'] * 4,
    '제품': ['A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B',
             'A', 'A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B', 'B'],
    '매출': np.random.randint(100, 500, 24)
})

pivot_table = sales_data.pivot_table(
    values='매출',
    index='지역',
    columns=['제품', '분기'],
    aggfunc='sum',
    fill_value=0
)

print(pivot_table.to_markdown())
| 지역   |   ('A', 'Q1') |   ('A', 'Q2') |   ('B', 'Q1') |   ('B', 'Q2') |
|:-------|--------------:|--------------:|--------------:|--------------:|
| 대구   |           503 |           249 |           667 |           521 |
| 부산   |           648 |           345 |           662 |           591 |
| 서울   |           661 |           695 |           507 |           417 |

8. 결론

이 문서는 Quarto의 다양한 레이아웃 기능을 테스트했습니다:

  • ✓ 단일/다중 컬럼 레이아웃
  • ✓ 사용자 정의 비율 레이아웃
  • ✓ 중첩된 복잡한 레이아웃
  • ✓ 그림 배치 및 크기 조정
  • ✓ 여백 및 전체 너비 활용
  • ✓ 탭셋 및 접을 수 있는 요소
  • ✓ 반응형 그리드 시스템
  • ✓ 다양한 형태의 테이블 레이아웃
  • ✓ 테이블과 그래프 조합
  • ✓ 피벗 테이블 및 복잡한 데이터 표현