Reputation: 135
I am practicing data exploration with seaborn, and recently encountered a problem: how to pass alpha (transparency) into seaborn.jointplot
(onto the scatter plot part, not the histogram)?
More broadly, I would also like to know:
What are the general functions of joint_kws
, marginal_kws
and annot_kws
(i.e. how do I use/pass pyplot parameters into these parameters?)?
What is the difference between these parameters and the kwargs
parameter?
Thank you!
Upvotes: 6
Views: 6469
Reputation: 2886
Just adding alpha=0.5
to your sns.jointplot
call may give the following error:
TypeError: regplot() got an unexpected keyword argument 'alpha'
So in this case, you would nest this alpha
setting into the scatter_kws
, then into joint_kws
, like so:
sns.jointplot(x, y, data, kind='reg',joint_kws = {'scatter_kws':dict(alpha=0.5)})
At which point, you will get adjustment of transparancy for the scatter in the jointplot.
Upvotes: 6
Reputation: 10590
As noted in the comments, you can simply add alpha=0.5
into your jointplot
call.
As for your other questions, general information can be found in the documentation:
You pass a dictionary to each of the kw
parameters. These control the different portions of the plot created by jointplot
. For instance, if you wanted to change the transparency of the histogram, you would pass it to marginal_kws
. (This is a little bit more involved though since the "marginal" is created using sns.distplot
which builds off plt.hist
. So you would actually have marginal_kws={'hist_kws': {'alpha': 0.1}}
for jointplot
.
Additional kwargs
affect the scatter plot portion, just like joint_kws
will. These arguments, however, will supersede those provided by joint_kws
.
Upvotes: 0