简体   繁体   English

如何更改Seaborn对图中的回归模型

[英]How to change regression model in seaborn pairplot

I can create regression plot with seaborns regplot , where I can change the order of the linear regression model with the order option, or choose a lowess model with the lowess=True option as in: 我可以使用seaborns regplot创建回归图,在其中可以使用order选项更改线性回归模型的order ,也可以使用lowess=True选项选择lowess模型,如下lowess=True

sns.regplot(x='logAssets', y='logLTIFR', lowess=True, data=df, scatter_kws={'alpha':0.15}, line_kws={'color': 'red'})

and obtain this: 并获得此:

在此处输入图片说明

Is it possible to change the order of the linear regression in a pairplot ? 可以更改pairplot线性回归的pairplot吗?

Or even better, to use a lowess model in seaborn pairplot ? 甚至更好的是,在海洋pairplot对图中使用最低模型?

For more advanced usage, use PairGrid instead of pairplot . 对于更高级的用法,请使用PairGrid而不是pairplot Basically, PairGrid allows you to control which function is used to plot the upper, lower and diagonal plots independently. 基本上, PairGrid允许您控制使用哪个函数分别绘制上,下和对角线图。 Check out the documentation for PairGrid for more details. 有关更多详细信息,请查看PairGrid的文档。

To answer your specific question: 要回答您的特定问题:

iris = sns.load_dataset("iris")
g = sns.PairGrid(iris)
g = g.map_upper(sns.regplot, lowess=True, scatter_kws={'alpha':0.15}, line_kws={'color': 'red'})

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM