リレーショナルプロットとサブプロットの概要

Seaborn を使ったデータ可視化入門

Content Team

DataCamp

量的変数に関する質問

リレーショナルプロット

  • 身長と体重

Scatter plot of height versus weight

Seaborn を使ったデータ可視化入門

量的変数に関する質問

リレーショナルプロット

  • 身長と体重
  • 学校の欠席回数と最終成績

Scatter plot of number of absences versus final grade

Seaborn を使ったデータ可視化入門

量的変数に関する質問

リレーショナルプロット

  • 身長と体重
  • 学校の欠席回数と最終成績
  • GDPと識字率

Scatter plot of GDP versus percent literate

Seaborn を使ったデータ可視化入門

Scatter plot with hue

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

Scatter plot with subplots

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

relplot()の紹介

  • 「リレーショナルプロット」を作成する:散布図または折れ線グラフ

  • scatterplot() ではなく relplot() を使う理由は?

  • relplot() では、1つの図にサブプロットを作成できる

Seaborn を使ったデータ可視化入門

scatterplot()とrelplot()の比較

scatterplot() の使い方

import seaborn as sns
import matplotlib.pyplot as plt

sns.scatterplot(x="total_bill", 
                y="tip", 
                data=tips)

plt.show()

relplot() を使用する

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips,
            kind="scatter")

plt.show()
1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

列方向のサブプロット

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips,
            kind="scatter",
            col="smoker")

plt.show()

Scatter plot with smoker subplots in columns

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

行方向のサブプロット

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips,
            kind="scatter",
            row="smoker")

plt.show()

Scatter plot with smoker subplots in rows

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

行と列のサブプロット

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips,
            kind="scatter",
            col="smoker",
            row="time")

plt.show()

Scatter plot with subplots for smoker and time

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

曜日ごとのサブグループ

Scatter plot with day subplots in columns

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

列を折り返す

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips,
            kind="scatter",
            col="day",
            col_wrap=2)

plt.show()

Scatter plot with day subplots in columns in two rows

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

列の並べ替え

import seaborn as sns
import matplotlib.pyplot as plt

sns.relplot(x="total_bill", 
            y="tip", 
            data=tips,
            kind="scatter",
            col="day",
            col_wrap=2,
            col_order=["Thur",
                       "Fri",
                       "Sat",
                       "Sun"])

plt.show()

Scatter plot with ordered day subplots

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn を使ったデータ可視化入門

練習しましょう!

Seaborn を使ったデータ可視化入門

Preparing Video For Download...