Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change scatter point size on Seaborn's relplot (seaborn.relplot not regplot)? Seaborn 0.9.0

I would like to change the size of the scatter points.

None of these work:

sns.relplot(x='columnx', y='columny', hue='cluster', data=df)

sns.relplot(x='columnx', y='columny', hue='cluster', scatter_kws={'s':.01}, data=df)

sns.relplot(x='columnx', y='columny', hue='cluster', kwargs={'s':.01}, data=df)

like image 685
Bstampe Avatar asked Jul 25 '18 16:07

Bstampe


People also ask

How to control the size of the points in Seaborn scatterplot?

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. In this method, we specify the required variable as the value of this parameter.

How to change the figure size of a seaborn plot in Python?

There are two ways to change the figure size of a seaborn plot in Python. The first method can be used to change the size of “axes-level” plots such as sns.scatterplot () or sns.boxplot () plots: sns.set(rc= {"figure.figsize": (3, 4)}) #width=3, #height=4

How to increase the size of scatter points in Matplotlib scatter plot?

The points in the graph look scattered, hence the plot is named as ‘Scatter plot’. The points in the scatter plot are by default small if the optional parameters in the syntax are not used. The optional parameter ‘s’ is used to increase the size of scatter points in matplotlib. Discussed below are various ways in which s can be set.

How to increase or decrease the figure size in Seaborn?

Now, whether you want to increase, or decrease, the figure size in Seaborn you can use matplotlib. . Note, this code needs to be put above where you create the Seaborn plot.


2 Answers

Since the underlying function is matplotlib.pyplot.scatter(x, y, s=None), filling in the s=None to a suitable integer changes the size of ALL the points.

sns.relplot(x='columnx', y='columny', hue='cluster', data=df, s=10)
like image 122
Bstampe Avatar answered Oct 27 '22 01:10

Bstampe


Given your data and question choose your size between 1 and some larger number and figure out what works for you with the s argument as mentioned above. Just being more clear on how the end code should look.

sns.relplot(
    x='columnx', y='columny', hue='cluster', data=df, s=10)
like image 35
Christopher Matthews Avatar answered Oct 27 '22 01:10

Christopher Matthews