Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change marker size in seaborn.catplot

enter image description hereSo I have this code which generates a plot:

g=sns.catplot(data=public, x="age", y="number", col="species", kind="strip",
              jitter=True, order=order,
              palette=palette, alpha=0.5,linewidth=3,height=6, aspect=0.7)

How to I change markers size?

size=20 acts weird and seems to zoom the plot area instead of changing markers size. And i get:

'.conda-envs/py3/lib/python3.5/site-packages/seaborn/categorical.py:3692: UserWarning: The size paramter has been renamed to height; please update your code. warnings.warn(msg, UserWarning'

like image 397
Mark Izraelson Avatar asked Oct 24 '19 19:10

Mark Izraelson


People also ask

How do you change 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 CI in Catplot?

cifloat or “sd” or None, optional. Size of confidence intervals to draw around estimated values. If “sd”, skip bootstrapping and draw the standard deviation of the observations.

What is Stripplot in Seaborn?

Strip plot It is used to draw a scatter plot based on the category. Syntax: seaborn.stripplot(*, x=None, y=None, hue=None, data=None, order=None, hue_order=None, jitter=True, dodge=False, orient=None, color=None, palette=None, size=5, edgecolor='gray', linewidth=0, ax=None, **kwargs)


2 Answers

Use s instead of size. the default s is 5.

Example:

sns.catplot(x = "time",
       y = "total_bill",
        s = 20,
       data = tips)

enter image description here

sns.catplot(x = "time",
       y = "total_bill",
        s = 1,
       data = tips)

enter image description here

like image 115
Swee Kwang Avatar answered Oct 23 '22 06:10

Swee Kwang


There is a conflict between the parameter 'size' in sns.stripplot and the deprecated 'size' of sns.catplot, so when you pass 'size' to the latter, it overrides the 'height' parameter and shows the warning message you saw.

Workaround

From looking inside the source code, I've found that 's' is an alias of 'size' in sns.stripplot, so the following works as you expected:

g=sns.catplot(data=public, x="age", y="number", col="species", kind="strip",
              jitter=True, order=order, s=20,
              palette=palette, alpha=0.5, linewidth=3, height=6, aspect=0.7)
like image 22
Shovalt Avatar answered Oct 23 '22 07:10

Shovalt