중급 편 그래프의 마지막 단계
두 딸 들, 이제까지 정신없이 코딩에 대해 배워왔는데, 이에 중급, 그것도 중급 중 고급 단 게에 와 있어. 코딩이란 단순히 법칙을 외우는 것이 아니라 코딩의 결과 이런 것을 만들 수 있어를 배워야 해. 자동차의 원리도 모르고 전국 방방곡곡을 운전하며 달리듯이, 그리고 비행기를 타고 전 세계로 가듯이 누군가가 만들러 준 코드로
나의 꿈과 미래를 설계하는 방법을 배우는 거야. 인공지능도 다 내 손안에 있고 멋진 주식투자도 도우미도 만들 수 있어. 아빠가 이미 고급 편에 이런 내용을 소개할 20편 이상의 준비가 되어 있어.
이제는 아빠가 뒤이서 잡고 배우 주는 자전거 타기가 아니라, 우리 두 딸이 아빠가 "이제는 좀 그만 쉬어라 그러다 다칠라" 해도 자발적으로 동네 골목골목을 혼자서 유람하는 그런 날이 오고 있다고 믿어. 오늘은 2025년 마지막 편인데, 2026년을 기대하는 그런 새로운 개기가 되길 바라.
대시보드(Dashboard)는 여러 데이터를 한 화면에서 직관적으로 확인할 수 있도록 구성한 시각화 도구다. 자동차의 계기판이 속도·연료·온도 등을 한눈에 보여주듯, 데이터 대시보드는 여러 지표(KPI)를 동시에 보여주어 빠른 판단을 돕는 역할을 한다.
대시보드는 단순히 그래프를 나열하는 것이 아니라 다음과 같은 특징을 가진다.
요약 정보 제공: 전체 데이터 중 핵심만 추려서 보여준다.
실시간 또는 주기적 업데이트: 최신 상태를 즉시 확인할 수 있다.
상호작용성(Interactivity): 사용자가 직접 필터링, 선택, 확대 등을 할 수 있다.
의사결정 지원: 데이터를 “보는 것”을 넘어 “판단하는 것”까지 연결한다.
대시보드는 거의 모든 산업에서 사용된다. 대표적인 예시는 다음과 같다.
매출 추이, 고객 수, 재고 현황 등을 실시간으로 모니터링
경영진이 빠르게 의사결정을 내릴 수 있도록 지원
캠페인 성과 분석
유입 경로, 클릭률, 전환율 등을 시각화
센서 데이터 모니터링
장비 이상 감지 및 예측 유지보수
실험 데이터 시각화
학생 성취도 분석
서버 상태, 트래픽, 오류 로그 모니터링
내용은 무진장 긴데 그냥 이런 것이 있다는 의미로 만 생각해요. 아직은 여러분에게 어려워요.
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
# 한글 폰트 설정 (Windows)
plt.rcParams ['font.family'] = 'Malgun Gothic'
plt.rcParams ['axes.unicode_minus'] = False
# ============ 데이터 준비 ============
# 월별 데이터
months = ['1월', '2월', '3월', '4월', '5월', '6월',
'7월', '8월', '9월', '10월', '11월', '12월']
sales = [1000, 1200, 1100, 1500, 1800, 2000,
2100, 1900, 2200, 2500, 2300, 2600] # 만원 단위
profit = [200, 250, 220, 350, 450, 500,
520, 480, 550, 650, 600, 700] # 만원 단위
# ============ 대시보드 만들기 ============
fig = plt.figure(figsize=(15, 10))
fig.suptitle('2025년 사업결과 보고서', fontsize=20, fontweight='bold', y=0.98)
# 1. 월별 매출 (1번 위치)
ax1 = plt.subplot(2, 3, 1)
ax1.bar(months, sales, color='skyblue', edgecolor='navy', linewidth=1.5)
ax1.set_title('월별 매출', fontsize=14, fontweight='bold')
ax1.set_ylabel('매출 (만원)', fontsize=11)
ax1.tick_params(axis='x', rotation=45)
ax1.grid(axis='y', alpha=0.3)
# 2. 월별 영업이익 (2번 위치)
ax2 = plt.subplot(2, 3, 2)
ax2.plot(months, profit, marker='o', color='red', linewidth=2.5, markersize=8)
ax2.fill_between(range(len(months)), profit, alpha=0.3, color='red')
ax2.set_title('월별 영업이익', fontsize=14, fontweight='bold')
ax2.set_ylabel('영업이익 (만원)', fontsize=11)
ax2.tick_params(axis='x', rotation=45)
ax2.grid(alpha=0.3)
# 3. 매출 vs 영업이익 비교 (3번 위치)
ax3 = plt.subplot(2, 3, 3)
x = np.arrange(len(months))
width = 0.35
ax3.bar(x - width/2, sales, width, label='매출', color='skyblue', edgecolor='navy')
ax3.bar(x + width/2, profit, width, label='영업이익', color='lightcoral', edgecolor='darkred')
ax3.set_title('매출 vs 영업이익', fontsize=14, fontweight='bold')
ax3.set_ylabel('금액 (만원)', fontsize=11)
ax3.set_xticks(x)
ax3.set_xticklabels(months, rotation=45)
ax3.legend()
ax3.grid(axis='y', alpha=0.3)
# 4. 분기별 매출 (4번 위치)
ax4 = plt.subplot(2, 3, 4)
q1 = sum(sales [0:3])
q2 = sum(sales [3:6])
q3 = sum(sales [6:9])
q4 = sum(sales [9:12])
quarters = ['1분기', '2분기', '3분기', '4분기']
quarter_sales = [q1, q2, q3, q4]
colors = ['#FF6 B6 B', '#4 ECDC4', '#45 B7 D1', '#FFA07 A']
ax4.pie(quarter_sales, labels=quarters, autopct='%1.1f%%', colors=colors, startangle=90)
ax4.set_title('분기별 매출 비율', fontsize=14, fontweight='bold')
# 5. 요약 통계 (5번 위치)
ax5 = plt.subplot(2, 3, 5)
ax5.axis('off') # 축 숨기기
total_sales = sum(sales)
total_profit = sum(profit)
avg_sales = total_sales / 12
avg_profit = total_profit / 12
max_sales = max(sales)
min_sales = min(sales)
summary_text = f"""
� 2025년 연간 요약
총매출: {total_sales:,} 만원
총 영업이익: {total_profit:,} 만원
평균 월 매출: {avg_sales:,. 0f} 만원
평균 월 이익: {avg_profit:,. 0f} 만원
최고 매출월: {max_sales:,} 만원
최저 매출월: {min_sales:,} 만원
이익률: {(total_profit/total_sales)*100:. 1f}%
"""
ax5.text(0.1, 0.5, summary_text, fontsize=12, verticalalignment='center',
family='monospace', bbox=dict(boxstyle='round', facecolor='wheat', alpha=0.5))
# 6. 성장률 (6번 위치)
ax6 = plt.subplot(2, 3, 6)
growth_rate = [(sales [i] - sales [i-1]) / sales [i-1] * 100 if i > 0 else 0 for i in range(len(sales))]
colors_growth = ['green' if x > 0 else 'red' for x in growth_rate]
ax6.bar(months, growth_rate, color=colors_growth, edgecolor='black', linewidth=1)
ax6.axhline(y=0, color='black', linestyle='-', linewidth=0.8)
ax6.set_title('월별 성장률', fontsize=14, fontweight='bold')
ax6.set_ylabel('성장률 (%)', fontsize=11)
ax6.tick_params(axis='x', rotation=45)
ax6.grid(axis='y', alpha=0.3)
# 레이아웃 조정
plt.tight_layout()
plt.show()
print("✅ 2025년 사업결과 보고서가 완성되었습니다!")
다음 편에서도 자꾸 익숙해져 보자고요..