18

enter image description here

So 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'

Dan Bonachea
  • 2,408
  • 5
  • 16
  • 31
Mark Izraelson
  • 301
  • 1
  • 2
  • 6
  • 1
    What is your definition of weird ? compared to what ? what did you expect ? what did you obtain ? You should provide some input data (random generated will be fine) + some sample code + screen of graph with size value. – LoneWanderer Oct 24 '19 at 19:59
  • @ImportanceOfBeingernest pointed at that you may have older python/seaborn/matplotlib versions. You should provide that too. – LoneWanderer Oct 24 '19 at 20:25
  • Weird means: it changes the size of the plot area I think, I get a huge plot with little dots on it, instead of large markers. I have the last seaborn version. – Mark Izraelson Oct 25 '19 at 20:07

3 Answers3

19

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

d_kennetz
  • 5,219
  • 5
  • 21
  • 44
Swee Kwang
  • 724
  • 9
  • 15
5

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)
Shovalt
  • 6,407
  • 2
  • 36
  • 51
0

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 sns

sns.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=8 enter image description here

Community
  • 1
  • 1
LoneWanderer
  • 3,058
  • 1
  • 23
  • 41