Home > OS >  Widen strips in Seaborn stripplot
Widen strips in Seaborn stripplot

Time:10-12

Is there a keyword argument that can be passed to seaborn.stripplot so that each strip can be, say 2x wider than it would be by default?

enter image description here

In one of the example plots in the stripplot doc, the points for "tip" are too compact to really be distinguished. The size of each point could be decreased, but this works only up to a point. So it would seem useful if each strip could be widened to fill most of the plot, with bumpers in between each strip.

CodePudding user response:

The relevant parameter is jitter:

jitter: Amount of jitter (only along the categorical axis) to apply. This can be useful when you have many points and they overlap, so that it is easier to see the distribution. You can specify the amount of jitter (half the width of the uniform random variable support), or just use True for a good default.

Here are some examples of the default, jitter=0.2, and jitter=0.4:

import seaborn as sns
import matplotlib.pyplot as plt

tips = sns.load_dataset('tips')
fig, (ax1, ax2, ax3) = plt.subplots(1, 3)

sns.stripplot(ax=ax1, data=tips)
sns.stripplot(ax=ax2, data=tips, jitter=0.2)
sns.stripplot(ax=ax3, data=tips, jitter=0.4)

jitter comparison

  • Related