Questions tagged [swarmplot]

A swarm plot (also known as a "beeswarm plot") is a type of data visualization that presents a categorical scatterplot with non-overlapping points.

Description

A swarm plot (also known as a "beeswarm plot") is a type of data visualization that presents a categorical scatterplot with non-overlapping points. It can also be thought of as a variant of a , but with non-overlapping points.

This method of presentation can be helpful if you wish to plot a data distribution while retaining all of the individual data points, especially if many of your data points are concentrated within a narrow range. However, it is not recommended to use beeswarm plots when there are many data points, as the "swarming" can create visual artifacts.

Tools for producing swarm plots exist for programming languages/packages such as , , and . This tag should be used for any questions involving the formatting and/or implementation of these plots.

Implementations

Seaborn, for Python

The beeswarm package for R

Additional Resources

  • A blog post on swarm plots.
  • A data science blog post with advice on when and how to use swarm plots.
  • Examples of swarm plots made using D3
72 questions
3
votes
1 answer

Seaborn PairGrid with swarm plots

I have a dataset (kinda) like this: f1 f2 f3 value 4 2 3 0.927252 1 3 0 0.153415 0 1 1 0.928820 1 0 4 0.933250 0 4 3 0.397307 ... I want to produce a Seaborn PairGrid with stripplots with jitter or…
jdehesa
  • 58,456
  • 7
  • 77
  • 121
3
votes
1 answer

How to plot multiple swarmplots in a single figure?

I would like to plot multiple swarmplots in a single figure. I think swarmplot is one of the seaborn plots that should be able to do this, as it takes an axes keyword. However (with a freshly updated anaconda, matplotlib and seaborn) the following…
Tobias Wood
  • 139
  • 8
2
votes
1 answer

Plotting a swarmplot on a violinplot changes the ylim and truncates the violins

import seaborn as sns import numpy as np # for sample data import pandas as pd # sample data np.random.seed(365) rows = 60 data1 = {'Type 1': ['a'] * rows, 'Total': np.random.normal(loc=25, scale=3, size=rows)} data2 = {'Type 1': ['b'] *…
2
votes
1 answer

How to annotate swarmplot points on a categorical axis and labels from a different column

I’m trying to add labels to a few values in my matplotlib/seaborn plot. Not all, just those above a certain value (below, using iris from sklearn, labels for values greater than 3.6 on the x-axis). Here, from @Scinana, last year is a discussion of…
2
votes
2 answers

How to overlay data points on seaborn figure-level boxplots

I have the following dataframe and plot below - and I want to add data points for each box plot in the factorplot but I am having trouble combining box and strip plots in to the same graph (i.e. they dont overlay, they appear below each other). Is…
an10b3
  • 273
  • 1
  • 8
2
votes
0 answers

How do I add custom error bars in Seaborn swarm plot

I am trying to make a column scatter plot, like the ones you could normally produce with Graphpad. So far I have: import pandas as pd import seaborn as sns import matplotlib.pyplot as plt from scipy import stats sns.set(style="white",…
GZS
  • 21
  • 1
2
votes
1 answer

How to adjust transparency (alpha) in seaborn swarmplot?

I have a swarmplot: sns.swarmplot(y = "age gap corr", x = "cluster", data = scatter_data, hue = 'group', dodge=True) and I would like to adjust the transparency of the dots: sns.swarmplot(y = "age gap corr", x = "cluster", …
Xin Niu
  • 533
  • 1
  • 5
  • 15
2
votes
2 answers

Using seaborn's catplot with a single axis, but still specify hue

I'm trying to use swarmplot with a single axis, but where the data points are colored differently based on a category. Here is an example: import seaborn as sns import matplotlib.pyplot as plt import pandas as pd data = [ (12, 50, 'Free',…
Barry
  • 286,269
  • 29
  • 621
  • 977
2
votes
1 answer

How to change the position of a single swarm group

I am plotting a grouped bar plot on which I overlay a swarmplot and errorbars. One of the groups only have one bar, which I want to appear (with the swarm and the errorbar) in the middle of the location allocated to this group of bars. I managed to…
user1748101
  • 275
  • 1
  • 3
  • 9
2
votes
2 answers

Seaborn Swarmplot is running forever and not printing plot in Jupyter Notebook

Pandas dataframe have "user_fair , user_good, rating" these 3 columns. I am using sns.swarmplot to plot "user_fair vs rating" and "user_good vs rating". "user_fair vs rating" works fine but when try to plot "user_good vs rating" the code runs…
2
votes
2 answers

Horizontal plot in swarmplot of seaborn

Situation I have the following pandas dataset: |user_id|total|is_fat| |-------|-----|------| |1 |100 |1 | |2 |150 |0 | |3 |400 |1 | |4 |500 |1 | |5 |10 |0 | where elements of the total are integer…
s_narisawa
  • 51
  • 5
2
votes
1 answer

Seaborn swarmplot and pointplot dodge alignment

Is there a way to align the mean+SEM of a pointplot and the corresponding swarmplot? Here is my code: import seaborn as sns import numpy as np import pandas as pd import matplotlib.pyplot as plt fig, ax = plt.subplots(nrows=1,…
Ale
  • 133
  • 7
2
votes
1 answer

Specify color in catplot

I would like to specify the color of particular observations using seaborn catplot. In a made up exemple: import seaborn as sns import random as…
Nabla
  • 1,509
  • 3
  • 20
  • 35
2
votes
2 answers

Plotting colored lines connecting individual data points of two swarmplots

I have: import numpy as np import pandas as pd import seaborn as sb import matplotlib.pyplot as plt # Generate random data set1 = np.random.randint(0, 40, 24) set2 = np.random.randint(0, 100, 24) # Put into dataframe and plot df =…
MichlF
  • 139
  • 1
  • 8
2
votes
1 answer

Combine (overlay) two factorplots in matplotlib

I need to add swarmplot to boxplot in matplotlib, but I don't know how to do it with factorplot. I think I can iterate with subplots, but I would like to learn how to do it with seaborn and factorplot. A simple example (plotting by using the same…
Arnold Klein
  • 2,956
  • 10
  • 31
  • 60