Pengantar plot relasional dan subplot

Pengantar Visualisasi Data dengan Seaborn

Content Team

DataCamp

Pertanyaan tentang variabel kuantitatif

Plot relasional

  • Tinggi vs. berat

Plot sebar tinggi versus berat

Pengantar Visualisasi Data dengan Seaborn

Pertanyaan tentang variabel kuantitatif

Plot relasional

  • Tinggi vs. berat
  • Jumlah absen sekolah vs. nilai akhir

Plot sebar jumlah absen versus nilai akhir

Pengantar Visualisasi Data dengan Seaborn

Pertanyaan tentang variabel kuantitatif

Plot relasional

  • Tinggi vs. berat
  • Jumlah absen sekolah vs. nilai akhir
  • PDB vs. persentase melek huruf

Plot sebar PDB versus persentase melek huruf

Pengantar Visualisasi Data dengan Seaborn

Plot sebar dengan hue

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Plot sebar dengan subplot

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Mengenal relplot()

  • Buat "plot relasional": plot sebar atau plot garis

Mengapa gunakan relplot() alih-alih scatterplot()?

  • relplot() memungkinkan membuat subplot dalam satu figur
Pengantar Visualisasi Data dengan Seaborn

scatterplot() vs. relplot()

Menggunakan scatterplot()

import seaborn as sns
import matplotlib.pyplot as plt

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

plt.show()

Menggunakan 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: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Subplot per kolom

import seaborn as sns
import matplotlib.pyplot as plt

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

plt.show()

Plot sebar dengan subplot per perokok di kolom

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Subplot per baris

import seaborn as sns
import matplotlib.pyplot as plt

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

plt.show()

Plot sebar dengan subplot per perokok di baris

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Subplot di baris dan kolom

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()

Plot sebar dengan subplot untuk perokok dan waktu

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Subkelompok untuk hari dalam minggu

Plot sebar dengan subplot hari di kolom

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Membungkus kolom

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()

Plot sebar dengan subplot hari di kolom dalam dua baris

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Mengurutkan kolom

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()

Plot sebar dengan subplot hari yang diurutkan

1 Waskom, M. L. (2021). seaborn: visualisasi data statistik. https://seaborn.pydata.org/
Pengantar Visualisasi Data dengan Seaborn

Ayo berlatih!

Pengantar Visualisasi Data dengan Seaborn

Preparing Video For Download...