Hi all, I am trying to plot a weighted density plot for two different types and want to show the data points on the x axis.
The code is as follows. The data points are very concentrated. Is there a better way to present it( should I set the alpha value or something else)? Thanks! YL library(ggplot2) x <- rnorm(10000) a <- rnorm(5000) b <- rnorm(5000) weights.x <- abs(a/sum(a)) weights.y <- abs(b/sum(b)) weight <- c(weights.x, weights.y) ze <- rep(0,10000) type <- c(rep("a",5000), rep("b",5000)) d <- data.frame(expo = x, weight = weight, type = type, ze = ze) m <- ggplot(d, aes(x = expo, group = type, col = type, weight = weight)) m+geom_density()+geom_point(aes(x = expo, y = ze, shape = type)) ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.