Giới thiệu trực quan dữ liệu với Seaborn
Content Team
DataCamp
Nhập Seaborn:
import seaborn as sns
Nhập Matplotlib:
import matplotlib.pyplot as plt
Hiển thị biểu đồ:
plt.show()
sns.relplot(x="x_variable_name",
y="y_variable_name",
data=pandas_df,
kind="scatter")
sns.catplot(x="x_variable_name",
y="y_variable_name",
data=pandas_df,
kind="bar")
Thiết lập hue sẽ tạo các nhóm con với màu khác nhau trên cùng một biểu đồ.

Thiết lập row và/hoặc col trong relplot() hoặc catplot() sẽ tạo các nhóm con hiển thị trên các subplot riêng.

sns.set_style()sns.set_palette()sns.set_context()| Object Type | Plot Types | Cách thêm tiêu đề |
|---|---|---|
FacetGrid |
relplot(), catplot() |
g.figure.suptitle() |
AxesSubplot |
scatterplot(), countplot(), v.v. |
g.set_title() |
Thêm nhãn trục x và y:
g.set(xlabel="new x-axis label",
ylabel="new y-axis label")
Xoay nhãn vạch x:
plt.xticks(rotation=90)
Giới thiệu trực quan dữ liệu với Seaborn