0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

データ分析 スタックエリアチャート

Posted at

はじめに

データ分析をやる中でこれいいチャートだなと思うものがあったので、乗っけておきます。

📊 スタックエリアチャート(Stacked Area Chart)とは

スタックエリアチャートは、複数の系列データを“積み上げた形”で時系列に可視化するグラフです。

  • 各系列の値を縦方向に積み上げ、その合計を時間軸(X軸)上にプロット
  • 系列ごとの“流れ(トレンド)”と「構成比」の両方を同時に把握できる

image.png


🧐 使うべきシーン・メリット

シーン・目的 理由・効果
全体のボリューム推移を見たい 各時点の合計値がひと目でわかる
構成比の変化を同時に確認したい 時系列における各カテゴリのシェア(%)や量の変化を把握
複数系列間のトレンド比較 系列ごとの増減を、他系列との重なりで直感的に理解できる
ダッシュボードやレポート 一枚で「全体感+内訳」を示す省スペースな可視化が可能

🚀 主な実例(ユースケース)

  1. Webアクセス解析

    • デバイス別(PC/モバイル/タブレット)のセッション数推移
    • チャネル別(Organic/Paid/Referral)の流入シェア
  2. 売上分析

    • 商品カテゴリ別の月次売上トレンド
    • 地域別・店舗別の売上構成比
  3. システム監視

    • サーバーリソース(CPU/メモリ/ディスク)の利用率推移
    • マイクロサービス間のリクエスト数分布
  4. コールセンター運営

    • 問い合わせ種別(商品質問/クレーム/サポート)の時間帯別推移
    • 月間チャット・電話・メールでの対応件数比較
  5. プロジェクト管理

    • タスクステータス(未着手/進行中/完了)の日次推移
    • リソース配分(要員A/要員B/要員C)の工数シェア
# 📌 Google Colab 専用:日本語フォントのインストール
!apt-get -y install fonts-ipafont-gothic > /dev/null

# 📦 必要なライブラリ
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties

# 🎌 フォント設定
jp_font = FontProperties(fname="/usr/share/fonts/opentype/ipafont-gothic/ipag.ttf")
plt.rcParams['font.family'] = jp_font.get_name()

# 📊 サンプルデータの作成
data = {
    'hour': list(range(24)),
    'product_inquiry':  [0,0,0,0,0,5,20,50,60,55,50,40,30,25,20,15,10,10,5,3,2,1,0,0],
    'delivery_issue':   [0,0,0,0,0,2,10,30,40,45,40,35,30,25,20,15,10,10,5,3,1,0,0,0],
    'complaint':        [0,0,0,0,0,1,5,15,20,18,15,13,12,10,8,7,6,5,4,3,2,1,1,0],
    'refund_request':   [0,0,0,0,0,0,3,8,10,12,10,9,8,7,6,5,4,3,3,2,1,1,0,0],
}

df = pd.DataFrame(data)

# 📈 グラフの描画
plt.figure(figsize=(10, 6))
plt.stackplot(
    df['hour'],
    df['product_inquiry'],
    df['delivery_issue'],
    df['complaint'],
    df['refund_request'],
    labels=['商品について', '配送トラブル', 'クレーム', '返品・返金'],
    alpha=0.8
)

plt.title('1日のコールセンター問い合わせ状況', fontproperties=jp_font)
plt.xlabel('時間帯(時)', fontproperties=jp_font)
plt.ylabel('問い合わせ件数', fontproperties=jp_font)
plt.xticks(range(0, 24, 2))
plt.legend(loc='upper left', prop=jp_font)
plt.grid(True)
plt.tight_layout()
plt.show()

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?