Home > Blockchain >  How to set the linestyle for kde hue groups plotted in a sns.pairplot
How to set the linestyle for kde hue groups plotted in a sns.pairplot

Time:11-25

I use pairplot with density plot on diagonal positions, but the line style for different groups are the same. Is there a way to use different line styles for different groups?

Any help is appreciated!

import seaborn as sns
import matplotlib.pyplot as plt

iris = sns.load_dataset("iris")

g = sns.pairplot(iris, kind="scatter", 
                 hue = 'species', 
                 diag_kind='auto',
                 diag_kws={'bw_adjust':.03, 'linestyle':['solid','dotted', 'dashed', 'dashdot']},
                 # this does not work with error: Unrecognized linestyle: ['solid', 'dotted', 'dashed', 'dashdot'], same for: {'solid','dotted', 'dashed', 'dashdot'}
                 #diag_kws={'bw':.03, 'linestyle':'dotted'} # this works but has identical line style for species.
                )
plt.show()
  • The solution for updating linestyles for hue groups offered in enter image description here

  • Related