Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove white border from dots in a seaborn scatterplot

The scatterplot from seaborn produces dots with a small white boarder. This is helful if there are a few ovelapping dots, but it becomes really impractical once there are many overlaying dots. How can the white borders be removed?

import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
ax = sns.scatterplot(x="total_bill", y="tip", data=tips)

A seaborn scatterplot of the tips dataset.

like image 645
fabianegli Avatar asked Jul 03 '20 13:07

fabianegli


People also ask

How do you reduce marker size in seaborn?

To set the size of markers, we can use the s parameter. This parameter can be used since seaborn is built on the matplotlib module. We can specify this argument in the scatterplot() function and set it to some value. Alternatively, we can control the size of the points based on some variables.

What is the seaborn Despine () function used for?

The despine() is a function that removes the spines from the right and upper portion of the plot by default. sns. despine(left = True) helps remove the spine from the left.

How do you change markers in seaborn?

Changing Marker Color on a Scatter Plot Behind the scenes, Seaborn scatter plots use the Matplotlib color styles. Here are the color codes for the basic colors you can use for your scatter plot markers. Pass the value in the argument column to the color parameter to change your marker colors.


3 Answers

Instead of edgecolors use linewidth = 0:

import seaborn as sns; sns.set()
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
ax = sns.scatterplot(x="total_bill", y="tip", data=tips, linewidth=0)
like image 82
ipj Avatar answered Nov 14 '22 23:11

ipj


If you check searbon documentation, it accepts matplotlib keywords (listed kwargs in seaborn functions' documentaion), therefore, you can either pass, as sugested by @Allan Bruno edgecolor = 'none', edgecolor = None (singular, not 'edgecolors'), or linewidth = 0

Output:

enter image description here

like image 24
dm2 Avatar answered Nov 14 '22 21:11

dm2


Try passing the argument edgecolor='none' or edgecolor=None into sns.scatterplot()

like image 41
savingDuck468 Avatar answered Nov 14 '22 23:11

savingDuck468