我正在尝试绘制散点图,其中每个点都用变量Points着色。此外,我还想添加回归线。
import pandas as pd
import urllib3
import seaborn as sns
decathlon = pd.read_csv("https://raw.githubusercontent.com/leanhdung1994/Deep-Learning/main/decathlon.txt", sep='\t')
g = sns.lmplot(
data = decathlon,
x="100m", y="Long.jump",
hue = 'Points', palette = 'viridis'
)

在我看来,有两条回归线,每组数据一条。这不是我想要的。我希望对整个数据有一条回归线。此外,如何隐藏右侧的图例?
您能详细说明一下如何做到这一点吗?
发布于 2020-10-26 20:38:36
除非需要使用FacetGrid将数据集分割为多个子图,否则不应使用lmplot。
由于您显示的示例没有使用FacetGrid提供的任何功能,因此您应该使用scatterplot()和regplot()的组合来创建绘图
tips = sns.load_dataset('tips')
ax = sns.scatterplot(data=tips, x="total_bill", y="tip", hue="day")
sns.regplot(data=tips, x="total_bill", y="tip", scatter=False, ax=ax)

https://stackoverflow.com/questions/64535637
复制相似问题