如何将seaborn regplot scattplot更改为lineplot?

时间:2020-10-19 23:16:31

标签: python matplotlib seaborn

我正在尝试将散点图更改为我尝试使用plot.lines[0].set_linestyle("-")的线图,但这只会影响已经是线图的回归线。

我了解我是否使用sns.lineplot是他们启用回归的设置,但是我正尝试使用regplot做到这一点。

df = pd.DataFrame({"x": [1, 2, 3, 4, 5, 6], "y": [10, 30, 60, 90, 60, 30]})

plot = sns.regplot(x="x", y="y", data=df, ci=65)

plt.show()

我想将散点图更改为线图的原因是,因为很难看到大型数据集的其他原因。

为澄清起见,我正在尝试显示原始数据的线图而不是散点图。

1 个答案:

答案 0 :(得分:1)

这看起来有些奇怪,但是我猜这就是您想要的吗?

import seaborn as sns
df = pd.DataFrame({"x": [1, 2, 3, 4, 5, 6], "y": [10, 30, 60, 90, 60, 30]})
sns.regplot(x="x", y="y", data=df, ci=65,scatter=False)
sns.lineplot(x="x", y="y", data=df)

enter image description here