如何在seaborn pairplot中调整透明度(alpha)? [英] How to adjust transparency (alpha) in seaborn pairplot?

查看:151
本文介绍了如何在seaborn pairplot中调整透明度(alpha)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用seaborns regplot 创建美丽的散点图,并通过

I can create beatiful scatter plot with seaborns regplot, obtain the right level of transparency through the scatter_kws as in

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

并获得:

seaborn pairplot 中是否有调整透明度的选项?

Is there an option in a seaborn pairplot to tweak transparency?

推荐答案

好的,我非常接近解决方案.Seaborn的 pairplots 具有 plot_kws ,该字典将您将在 regplot 中进行的修改类型的字典作为参数.以下行正是我所需要的:

Ok I was very close to the solution. Seaborn pairplots have plot_kws that takes as arguments a dictionary of the kind of modifications you would do in a regplot. The following line is exactly what I needed:

g = sns.pairplot(df, kind='reg', plot_kws={'line_kws':{'color':'red'}, 'scatter_kws': {'alpha': 0.1}})

这是结果:

如果您不做回归而只做散点图 (kind='scatter'),则在 plot 关键字内,您不必在 line 和 scatter 关键字之间进行划分:

If you don't do the regression but just the scatter plot (kind='scatter'), within plot keywords you don't have to do the division between line and scatter keywords:

g = sns.pairplot(df, kind='scatter', plot_kws={'alpha':0.1})

这篇关于如何在seaborn pairplot中调整透明度(alpha)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆