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.
July 30, 2015: beeswarm is now on GitHub.
May 4, 2015: Version 0.2.0 is now available from CRAN. New features:
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"')