3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Seaborn定量比較-散布図

Last updated at Posted at 2021-06-15

散布図とは

定義はMatplotlib定量比較-散布図をご参考ください。

簡単な散布図

Seabornで散布図を描くには、scatterplotとrelplot(relational plot)の2つの方法があります。

scatterplotの場合:

import matplotlib.pyplot as plt
import seaborn as sns

sns.scatterplot(x='col01', y='col02', data=test_data)

plt.show()

image.png

relplotの場合:

import matplotlib.pyplot as plt
import seaborn as sns

sns.relplot(x='col01', y='col02', data=test_data, kind='scatter')

plt.show()

image.png

サブプロットで複数の散布図を描く

relplotのcolとrowパラメータで、横と縦で複数の散布図を描けます。

sns.relplot(x="G1", y="G3", 
            data=student_data,
            kind="scatter", 
            col="schoolsup",
            col_order=["yes", "no"], 
            row='famsup', 
            row_order=["yes", "no"])

plt.show()

image.png

常用オプション

  • size: 点のサイズ
  • hue: 点の色
sns.relplot(x='col01', y='col02', data=test_data, kind='scatter', size='cylinders', hue='cylinders')

plt.show()

image.png

  • style: 点のスタイル
sns.relplot(x='col01', y='col02', data=test_data, kind='scatter', hue='origin', style='origin')

plt.show()

image.png

3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?