Python 如何在seaborn pairplot中调整透明度(alpha)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47200033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to adjust transparency (alpha) in seaborn pairplot?
提问by famargar
I can create beatiful scatter plot with seaborns regplot
, obtain the right level of transparency through the scatter_kws
as in
我可以创建seaborns beatiful散点图regplot
,通过获得的透明度权水平scatter_kws
为
sns.regplot(x='logAssets', y='logLTIFR', lowess=True, data=df, scatter_kws={'alpha':0.15}, line_kws={'color': 'red'})
and obtain this:
并获得这个:
Is there an option in a seaborn pairplot
to tweak transparency?
seaborn 中是否有pairplot
调整透明度的选项?
回答by famargar
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:
好的,我非常接近解决方案。Seabornpairplots
有plot_kws
作为的名字需要类型的修改,你会在做一本字典regplot
。以下行正是我所需要的:
g = sns.pairplot(df, kind='reg', plot_kws={'line_kws':{'color':'red'}, 'scatter_kws': {'alpha': 0.1}})
And this is the outcome:
这是结果:
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:
如果您不做回归而只做散点图 (kind='scatter'),则在 plot 关键字中,您不必在 line 和 scatter 关键字之间进行划分:
g = sns.pairplot(df, kind='scatter', plot_kws={'alpha':0.1})
回答by famargar
Alpha can be set as a keyword argument as so:
Alpha 可以设置为关键字参数,如下所示:
g = sns.pairplot(df, kind='scatter', alpha=0.1})