How to change marker size in seaborn.catplot How to change marker size in seaborn.catplot python-3.x python-3.x

How to change marker size in seaborn.catplot


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


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)


According catplot doc https://seaborn.pydata.org/generated/seaborn.catplot.html the underlying stripyou are using is documented here: https://seaborn.pydata.org/generated/seaborn.stripplot.html#seaborn.stripplot

Quoting:

size : float, optional

Diameter of the markers, in points. (Although plt.scatter is used to draw the points, the size argument here takes a “normal” markersize and not size^2 like plt.scatter).

So size=20 seems to be a perfectly valid parameter to give to catplot. Or any other value that suits your needs.

Copy pasta code with screens from seaborn documentation pages provided above...

import seaborn as snssns.set(style="whitegrid")tips = sns.load_dataset("tips")ax = sns.stripplot(x=tips["total_bill"])ax = sns.stripplot("day", "total_bill", "smoker", data=tips, palette="Set2", size=20, marker="D", edgecolor="gray",                   alpha=.25)

enter image description here

with size=8enter image description here