Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove marker edges in seaborn.pairplot()?

Seaborn has a handy function pairplot to create a matrix of scatter plots. Unfortunately, some standard matplotlib commands don't work with it.

sns.pairplot(matrix[cols[:4]].head(100), plot_kws=dict(alpha=.5, mew=0))

The markers get some ugly white edges. I tried mew for markeredgewidth keyword to remove them as it would be used in matplotlib, but that is an unknown property for seaborn. How can I remove these edges?

like image 966
Soren Avatar asked Mar 05 '23 16:03

Soren


2 Answers

A scatter does not have a mew keyword. It is edgecolor instead. Hence

sns.pairplot(data, plot_kws=dict(edgecolor="none"))

would remove the white edge around the scatterpoints.

like image 140
ImportanceOfBeingErnest Avatar answered Mar 17 '23 02:03

ImportanceOfBeingErnest


ImportanceOfBeingErnest's answer is much more precise. Alternatively, you can also use a workaround: Set the color of choice for both the face and the edges of the markers as (example from the docs)

import seaborn as sns
sns.set(style="ticks", color_codes=True)
iris = sns.load_dataset("iris")
g = sns.pairplot(iris, plot_kws=dict(facecolor='b', edgecolor="b"))

EDIT based on comments below IOBE's answer: Just specifying the linewidth=0 also works the same way on markers as specifying edgecolor="none".

g = sns.pairplot(iris, plot_kws=dict(linewidth=0))

enter image description here

like image 37
Sheldore Avatar answered Mar 17 '23 00:03

Sheldore