library(ggplot2) x <- rep(c(0, 0.5, 1), each = 100) y <- rep(c(0, 0.5, 0), each = 100) z <- rep(c("a", "b", "c"), each = 100) clust1 <- data.frame( x = x + rnorm(300, sd = 0.3), y = y + rnorm(300, sd = 0.3), z = z) clust2 <- data.frame( x = x + rnorm(300, sd = 0.1), y = y + rnorm(300, sd = 0.1), z = z)