Seaborn 数据可视化入门
Content Team
DataCamp
关系图

关系图

关系图



为何用 relplot() 而非 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()
import seaborn as sns import matplotlib.pyplot as plt sns.relplot(x="total_bill", y="tip", data=tips, kind="scatter", col="smoker")plt.show()

import seaborn as sns import matplotlib.pyplot as plt sns.relplot(x="total_bill", y="tip", data=tips, kind="scatter", row="smoker")plt.show()

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


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

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

Seaborn 数据可视化入门