Search code examples
parametersseabornalpha

How to pass alpha (transparency) into seaborn.jointplot?


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:

  1. 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?)?

  2. What is the difference between these parameters and the kwargs parameter?

Thank you!


Solution

  • 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.