Beeswarms instead of histograms
This article is originally published at https://aghaynes.wordpress.com
Histograms are good, density plots are also good. Violin and bean plots too. Recently I had someone ask for a plot where you could see each individual point along a continuum, give the points specific colours based on a second variable (similar to the figure), which deviates somewhat from the typical density type plots. Apparently, they’re called beeplots or beeswarms. And there’s a way to make them in R (of course, there’s probably more than one… ggplot2??).
Here’s one way (slightly modified from the packages help files)…
library(beeswarm) # assuming you've installed it ;) data(breast) beeswarm(time_survival ~ ER, data = breast, pch = 16, pwcol = 1 + as.numeric(event_survival), xlab = "", ylab = "Follow-up time (months)", horizontal = TRUE, labels = c("ER neg", "ER pos"), method = "c") legend("topright", legend = c("Yes", "No"), title = "Censored", pch = 16, col = 1:2)
Horizontal is optional of course…
Feel free to comment if you know of other approaches.
Hope that helps someone
UPDATE… I just remembered…these plots are also sometimes referred to as turnip plots…
Please visit source website for post related comments.