Search code examples
pythonseabornswarmplot

Variable sized markers in seaborn swarmplots


For a seaborn swarmplot, I'd like to give different points different marker sizes.

In the snippet below, for example, I want to use the marker_size key in plot_data to specify the size of the points in the swarmplot. According to the seaborn documentation, swarmplot takes a size parameter, but it has to be a float, so I can't use it for what I want to do.

Here is my code:

import seaborn as sns
import numpy as np
N = 100
plot_data = dict(category=np.random.choice([1, 2, 3], size=N), 
                 values=np.random.randn(N), 
                 marker_size=np.arange(N))
sns.swarmplot(x="category", y="values", data=plot_data)

Does anyone know what I can do to specify different point sizes for the swarmplot?


Solution

  • As per @mwaskom's comment, this is not possible in Seaborn.