Skip to content

Instantly share code, notes, and snippets.

@epijim
Created October 1, 2013 13:26
Show Gist options
  • Save epijim/6778422 to your computer and use it in GitHub Desktop.
Save epijim/6778422 to your computer and use it in GitHub Desktop.
swarmplot, visualise continuous distribution by a catergorical stratification variable.
# data
set.seed(1234)
bimodal <- c(rnorm(250, -2, 0.6), rnorm(250, 2, 0.6))
uniform <- runif(500, -4, 4)
normal <- rnorm(500, 0, 1.5)
dataf <- data.frame (group = rep(c("bimodal","uniform", "normal"), each = 500), xv = c(bimodal, uniform, normal), cg = rep( c("A","B"), 750))
require(beeswarm)
# hexagon
beeswarm(xv ~ group, data = dataf,
method = 'hex',
pch = 16, pwcol = as.numeric(cg),
xlab = '', ylab = 'xv',
labels = c('bimodal', 'uniform', 'normal'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment