Table of Contents
To change the marker size in a Seaborn scatterplot, the “size” parameter can be specified in the “scatterplot” function. The size can be set to a numerical value or a categorical variable, allowing for customization of the marker size based on different variables. This can be useful for visualizing data with varying levels of importance or to highlight specific data points. By adjusting the marker size, the visual representation of the scatterplot can be easily modified to convey the desired message or insights.
Change Marker Size in Seaborn Scatterplot
You can use the s argument within the scatterplot() function to adjust the marker size in a seaborn scatterplot:
import seaborn as sns sns.scatterplot(data=df, x='x_var', y='y_var', hue='group_var', s=20)
The greater the value you provide for the s argument, the larger the points in the plot will be.
The following example shows how to use this syntax in practice.
Example: Change Marker Size in Seaborn Scatterplot
Suppose we have the following pandas DataFrame that contains information about the sales made during five consecutive days at two different retail stores:
import pandas as pd
#create DataFrame
df = pd.DataFrame({'day': [1, 2, 3, 4, 5, 1, 2, 3, 4, 5],
'store': ['A', 'A', 'A', 'A', 'A',
'B', 'B', 'B', 'B', 'B'],
'sales': [3, 3, 5, 4, 7, 6, 8, 9, 12, 13]})
#view DataFrame
print(df)
day store sales
0 1 A 3
1 2 A 3
2 3 A 5
3 4 A 4
4 5 A 7
5 1 B 6
6 2 B 8
7 3 B 9
8 4 B 12
9 5 B 13We can use the scatterplot() function in seaborn to create a scatterplot that displays the sales made each day at each store
import seaborn as sns #create scatterplot with default marker size sns.scatterplot(data=df, x='day', y='sales', hue='store')

We can use the s argument to increase the size of the points in the plot:
import seaborn as sns #create scatterplot with increased marker size sns.scatterplot(data=df, x='day', y='sales', hue='store', s=200)

Notice that the size of the points has increased.
However, the size of the points in the legend have remained the same.
To increase the size of the points in the legend, you can use the markerscale argument within the matplotlib legend() function:
import matplotlib.pyplotas plt import seaborn as sns #create scatterplot with increased marker size sns.scatterplot(data=df, x='day', y='sales', hue='store', s=200) #increase marker size in legend plt.legend(markerscale=2)

Note that the default value for markerscale is 1.
By increasing this value, you can change the size of the markers relative to the originally drawn ones.
Feel free to play around with the s argument and markerscale argument to make the points in the scatterplot be the exact size that you’d like.
The following tutorials explain how to perform other common tasks in seaborn:
Cite this article
stats writer (2024). How can I change the marker size in a Seaborn scatterplot?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-change-the-marker-size-in-a-seaborn-scatterplot/
stats writer. "How can I change the marker size in a Seaborn scatterplot?." PSYCHOLOGICAL SCALES, 25 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-change-the-marker-size-in-a-seaborn-scatterplot/.
stats writer. "How can I change the marker size in a Seaborn scatterplot?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-change-the-marker-size-in-a-seaborn-scatterplot/.
stats writer (2024) 'How can I change the marker size in a Seaborn scatterplot?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-change-the-marker-size-in-a-seaborn-scatterplot/.
[1] stats writer, "How can I change the marker size in a Seaborn scatterplot?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I change the marker size in a Seaborn scatterplot?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
