n <- 1000
x1 <- rnorm(n)
x2 <- c(rnorm(n/2, mean=-2), rnorm(n/2, mean=2))
x3 <- c(rnorm(0.6*n, mean=-3), rnorm(0.2*n, mean=2), rnorm(0.2*n, mean=6))
set.seed(0)
png("modality.png", width=1260, height=420, bg="transparent")
par(mfrow=c(1,3))
hist(x1, axes=F, xlab="", ylab="", main="Unimodal", cex.main=3)
abline(v=mean(x1), lwd=2, col="red")
rug(x1)
hist(x2, axes=F, xlab="", ylab="", main="Bimodal", cex.main=3)
abline(v=mean(x2), lwd=2, col="red")
rug(x2)
hist(x3, axes=F, xlab="", ylab="", main="Multimodal", cex.main=3)
abline(v=mean(x3), lwd=2, col="red")
rug(x3)
dev.off()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.