Tùy chỉnh biểu đồ phân tán

Giới thiệu trực quan dữ liệu với Seaborn

Content Team

DataCamp

Tổng quan biểu đồ phân tán

Thể hiện quan hệ giữa hai biến định lượng

Đã xem:

  • Biểu đồ con (colrow)
  • Nhóm phụ theo màu (hue)

Tùy chỉnh mới:

  • Nhóm phụ theo kích thước và kiểu điểm
  • Thay đổi độ trong suốt điểm

Dùng với cả scatterplot()relplot()

Giới thiệu trực quan dữ liệu với Seaborn

Nhóm phụ theo kích thước điểm

import seaborn as sns
import matplotlib.pyplot as plt

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

plt.show()

Biểu đồ phân tán với kích thước điểm khác nhau

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Giới thiệu trực quan dữ liệu với Seaborn

Kích thước điểm và hue

import seaborn as sns
import matplotlib.pyplot as plt

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

plt.show()

Biểu đồ phân tán với kích thước và màu điểm khác nhau

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Giới thiệu trực quan dữ liệu với Seaborn

Nhóm phụ theo kiểu điểm

import seaborn as sns
import matplotlib.pyplot as plt

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

plt.show()

Biểu đồ phân tán với màu và kiểu khác nhau

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Giới thiệu trực quan dữ liệu với Seaborn

Thay đổi độ trong suốt điểm

import seaborn as sns
import matplotlib.pyplot as plt

# Set alpha to be between 0 and 1
sns.relplot(x="total_bill", 
            y="tip", 
            data=tips, 
            kind="scatter", 
            alpha=0.4)

plt.show()

Biểu đồ phân tán với điểm trong suốt hơn

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Giới thiệu trực quan dữ liệu với Seaborn

Ayo berlatih!

Giới thiệu trực quan dữ liệu với Seaborn

Preparing Video For Download...