I have plotted a pairplot in Seaborn with a hue, similar to the one shown below. I would like to add another hue by changing the shape of the markers based on another categorical feature. E.g., the example below was plotted using the penguin dataset. I would like to differentiate between data for male and female penguins by changing the marker shapes and adding another legend for each marker, whilst keeping the rest of the plot the same.

Example of Seaborn pairplot

Any ideas on how to do this are appreciated!


1 Answer 1


Not totally sure if this is exactly what you want, but you could create a column 'species_sex':

df['species_sex'] = df.sex + ' ' + df.species

Then plot:

                palette=['r', 'g', 'b', 'r', 'g', 'b'],
                markers=["o", "o", "o", 'D', 'D', 'D']);


Though I think you can see a bigger difference by just using different colors for all of the combinations:

sns.pairplot(df.sort_values('species_sex'), hue='species_sex')

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.