0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

🐳 seaborn チートシート

Last updated at Posted at 2025-05-18

📦 インポート&テーマ設定

import seaborn as sns
import matplotlib.pyplot as plt
# Jupyter Notebook上で、グラフをノートブックの中に表示させるためのおまじない
%matplotlib inline

sns.set_theme(style="darkgrid")  # 他に white, whitegrid, dark, ticks なども

📊 基本プロット

1️⃣ 散布図(scatterplot)

sns.scatterplot(x="x列", y="y列", data=df)
plt.title("散布図")
plt.show()

2️⃣ 線グラフ(lineplot)

sns.lineplot(x="日付", y="売上", data=df)
plt.title("売上推移")
plt.show()

3️⃣ 棒グラフ(barplot)

sns.barplot(x="カテゴリ", y="", data=df)
plt.title("カテゴリ別の値(平均)")
plt.show()

※ 合計にしたい場合:

sns.barplot(x="カテゴリ", y="", data=df, estimator=sum)

4️⃣ 箱ひげ図(boxplot)

sns.boxplot(x="カテゴリ", y="", data=df)
plt.title("値の分布と外れ値")
plt.show()

5️⃣ ヒストグラム(histplot)

sns.histplot(df[""], bins=20)
plt.title("値のヒストグラム")
plt.show()

6️⃣ カーネル密度推定(kdeplot)

sns.kdeplot(df[""], shade=True)
plt.title("密度分布")
plt.show()

🌈 相関・多変量プロット

🔥 相関ヒートマップ(heatmap)

corr = df.corr()
sns.heatmap(corr, annot=True, cmap="coolwarm")
plt.title("相関ヒートマップ")
plt.show()

🔍 ペアプロット(pairplot)

sns.pairplot(df)

🔄 カテゴリごとの分布(violinplot)

sns.violinplot(x="カテゴリ", y="", data=df)

🎨 カスタマイズTips

plt.title("タイトル")
plt.xlabel("X軸")
plt.ylabel("Y軸")
plt.xticks(rotation=45)
plt.tight_layout()

💡 おまけ:seabornの良いところ

特徴
🎨 デフォルトで美しい
🧠 統計処理が内蔵されてる(平均+CIなど)
🧩 pandasと相性バツグン
🪄 カテゴリの色分けやfacetingが簡単

0
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?