Hi:
Here's a way to plot your toy example using count as the y-axis rather
than density:
DF <- data.frame(x = rnorm(500))
library(ggplot2)
ggplot(DF, aes(x = x)) + geom_density(aes(y = ..count..), fill = "darkorange",
color = "darkorange", alpha = 0.5)
If you're plotting multiple densities in one graphics region, here's a
similar toy example:
DF2 <- data.frame(x1 = rnorm(500), x2 = rnorm(500, 1, 0.5))
library(reshape2)
DF2m <- melt(DF2)
ggplot(DF2m, aes(x = value, fill = variable)) +
geom_density(aes(y = ..count..), alpha = 0.5, color = NA)
To see why I used color = NA, try
ggplot(DF2m, aes(x = value, fill = variable, color = variable)) +
geom_density(aes(y = ..count..), alpha = 0.5)
Dennis