Swarm plot

Parveen Khurana
6 min readJan 16, 2021

A swarm plot is another way of plotting the distribution of an attribute or the joint distribution of a couple of attributes.

Let’s use the ‘diamonds’ dataset which is pre-loaded in the ‘seaborn’ package and have a swarm plot of the ‘carat’ attribute for the first 1000 data items

The ‘x-axis’ depicts the carat and this plot helps us to understand at what carat are there more diamonds or how the diamond count varies with carat size. It plots one dot for each data item(diamond in this case).

We can say that there are more diamonds with a carat size of 0.8 compared to the number of diamonds with a carat size as 0.6

Here is a swarm plot for the ‘price’ attribute based on a sample of 1000 data items

The distribution has many many diamonds at a low price and as price increases, the counts of diamonds fall down — the median price seems to be around the left side of the price axis but there is a long tail towards the right side.

If we just plot the first 1000 data items, we get the following figure:

--

--

Parveen Khurana
Parveen Khurana

Written by Parveen Khurana

Writing on Data Science, Philosophy, Emotional Health | Grateful for the little moments and every reader | Nature lover at heart | Follow for reflective musings

No responses yet