*beeswarm* is an add-on package for the R statistical environment.
The bee swarm plot is a one-dimensional scatter plot like "stripchart", but with closely-packed, non-overlapping points.

As with most R packages, *beeswarm* can be obtained from CRAN, or can can be downloaded and installed automatically by entering the following line at the R prompt:

install.packages('beeswarm')

Please send questions or comments about *beeswarm* to Aron.

May 4, 2015: **Version 0.2.0 is now available from CRAN.** New features:

- The swarm layout algorithm is a bit more efficient.
- New argument "side" allows swarms to expand in only one direction rather than two.
- New argument "priority" controls the order in which points are added to the swarm and thus the appearance of the plot.
- See examples of these new arguments below (at the very bottom of this page).

September 20, 2013: **Version 0.1.6 is now available from CRAN.** Minor new features:

- When a "corral" method is selected, the width of the swarms is determined automatically. Now, the default width can be overriden with the new argument "corralWidth".
- The "labels" argument now gets recycled.

May 7, 2012: **Version 0.1.5 is now available from CRAN.** Notable new features:

- Proper stratification of formulae such as x ~ y * z (i.e. now beeswarm splits into groups according to both y and z, as "boxplot" does)
- "beeswarm" now has methods (selected by the argument "corral") to control the spread of swarms into adjacent groups (see example below).
- New accessory function "bxplot", a minimalistic interpretation of "boxplot" for adding quantile lines to beeswarm plots (see example below).

Aug 4, 2011: **Version 0.1.1 is now available from CRAN.** This version fixes several bugs, offers improved support for logarithmic scales, and features new stand-alone functions to add swarms to an existing plot.
There are also minor interface changes; notably the "smile" method is now called "swarm", and this is now the default method.

library(beeswarm)

stripchart(decrease ~ treatment, data = OrchardSprays, vertical = TRUE, log = "y", method = 'jitter', jitter = 0.2, cex = 1, pch = 16, col = rainbow(8), main = 'stripchart') beeswarm(decrease ~ treatment, data = OrchardSprays, log = TRUE, pch = 16, col = rainbow(8), main = 'beeswarm')

data(breast) beeswarm(time_survival ~ ER, data = breast, pch = 16, pwcol = 1 + as.numeric(event_survival), xlab = "", ylab = "Follow-up time (months)", labels = c("ER neg", "ER pos")) legend("topright", legend = c("Yes", "No"), title = "Censored", pch = 16, col = 1:2)

## Generate some random data set.seed(123) distro <- list(runif = runif(100, min = -3, max = 3), rnorm = rnorm(100))

for (m in c("swarm", "center", "hex", "square")) { beeswarm(distro, col = 2:3, pch = 16, method = m, main = paste('method = "', m, '"', sep = '')) }

for (ii in c("none", "gutter", "wrap", "random", "omit")) { beeswarm(distributions, pch = 21, col = 2:4, bg = "#00000050", corral = ii, main = paste('corral = "', ii, '"', sep = '')) }

boxplot(len ~ dose, data = ToothGrowth, outline = FALSE, ## avoid double-plotting outliers, if any main = 'boxplot + beeswarm') beeswarm(len ~ dose, data = ToothGrowth, col = 4, pch = 16, add = TRUE) beeswarm(len ~ dose, data = ToothGrowth, col = 4, pch = 16, main = 'beeswarm + bxplot') bxplot(len ~ dose, data = ToothGrowth, add = TRUE)

beeswarm(distributions, col = 2:4, main = 'Default') beeswarm(distributions, col = 2:4, side = -1, main = 'side = -1') beeswarm(distributions, col = 2:4, side = 1, main = 'side = 1') beeswarm(distributions, col = 2:4, priority = "descending", main = 'priority = "descending"') beeswarm(distributions, col = 2:4, priority = "random", main = 'priority = "random"') beeswarm(distributions, col = 2:4, priority = "density", main = 'priority = "density"')