3

I need three densities (or smooth histograms) in the same plot. I am using ggplot, each variable has 1000 observations. Hence, the number of times a value can occur is a maximum of 1000 times. Suddenly my code produce extremely high counts for some values.

data <- read.table("mydata.txt", sep=",")
df <- data.frame(data)
df.m <- melt(data, variables=)
ggplot(den.m,aes(x=value, fill=variable)) + geom_density(alpha=0.25) 
+ ylab("Counts")

How to attach the data to this question?

Vladimir AC
  • 103
  • 1
  • 2
  • 6
  • 1
    you might want to see this page http://stackoverflow.com/questions/6957549/overlaying-histograms-with-ggplot2-in-r – akash87 Jun 14 '16 at 06:12
  • 9
    That code does not produce a plot with counts on the y-axis. It shows the probability density. Use `geom_density(aes(y = ..count..), alpha=0.25)` for that. – Axeman Jun 14 '16 at 07:31

0 Answers0