1

sns.pairplot This is my pairplot generated by sns.pairplot(). As you can see, the majority of the points belong to the blue, making it hard to find the others beneath the blue. So I want to make the blue semi-transparent while the other remain opaque, to show the red and the green more clearly.

When plot_kw 'alpha' of sns.pairplot is set, all the points will have the same transparency. So, it makes no improventment. How to apply the alpha keyword only to the blue? Because the number of the blue points is much more than the red and the green, making it hard to identify the red and the green which are covered by the blue.

Community
  • 1
  • 1
  • 2
    You will get a better chance at getting an answer if you provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve) including mock-up data. In particular, refer to [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) – Diziet Asahi Mar 12 '20 at 09:18

1 Answers1

2

You can use the hue_kws= argument of PairGrid to change the way the different hue levels are plotted:

iris = sns.load_dataset('iris')
g = sns.PairGrid(iris, hue="species", hue_kws={"alpha": [0.25,1,1]})
g = g.map_diag(sns.kdeplot, shade=True)
g = g.map_lower(plt.scatter)
g = g.add_legend()

enter image description here

Diziet Asahi
  • 38,379
  • 7
  • 60
  • 75