Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(ggplot2)
- x.centers <- c(0, .14, -.164)
- x.ses <- c(0.5, 0.2, 0.12)
- y.centers <- c(0.01,.13, -.13)
- y.ses <- c(0.05, 0.13, 0.24)
- NN <- 1000#00
- Sample1 <- cbind(rnorm(NN, x.centers[1], x.ses[1]), rnorm(NN, y.centers[1], y.ses[1]))
- Sample2 <- cbind(rnorm(NN, x.centers[2], x.ses[2]), rnorm(NN, y.centers[2], y.ses[2]))
- Sample3 <- cbind(rnorm(NN, x.centers[3], x.ses[3]), rnorm(NN, y.centers[3], y.ses[3]))
- PlotFrame <- data.frame(cbind(rep(c("G1", "G2", "G3"), each = NN), rbind(Sample1, Sample2, Sample3)))
- colnames(PlotFrame) <- c("LABELS", "X", "Y")
- PlotFrame[, 2:3] <- apply(PlotFrame[, 2:3], 2, as.numeric)
- Plot1 <- ggplot(data = PlotFrame, aes(x = X, y = Y, colour = LABELS))
- Plot1 <- Plot1 + geom_density2d()
- print(Plot1)
- Plot2 <- ggplot(data = PlotFrame, aes(x = X, y = Y, group = LABELS))
- Plot2 <- Plot2 + stat_density2d(aes(colour = ..level..), fill = "transparent", geom="polygon")
- print(Plot2)
- Plot3 <- ggplot(data = PlotFrame, aes(x = X, y = Y, group = LABELS))
- Plot3 <- Plot3 + stat_density2d(aes(fill = LABELS, colour = LABELS, alpha = ..level..), geom="polygon")
- print(Plot3)
Add Comment
Please, Sign In to add comment