Plot multiple histograms in R with prob=TRUE -
i want plot multiple histograms in r not show frequency, density instead:
a <- rnorm(100) b <- rnorm(100) hist1 <- hist(a,prob=true,breaks=30) hist2 <- hist(b,prob=true,breaks=30) plot(hist1, col="red",lty=0, xlim=c(-4,4)) plot(hist2, col="blue", lty=0, xlim=c(-4,4), add=true, main="example") lines(density(a))
however, 'prob=true' option apparently doesn't go through when plotting objects. can explain me doing wrong?
leave prob=t out of hist() command
hist1 <- hist(a,breaks=30) hist2 <- hist(b,freq=f,breaks=30)
and put freq=f
plot command.
plot(hist1, col="red",lty=0, xlim=c(-4,4),freq=f) plot(hist2, col="blue", lty=0, xlim=c(-4,4), add=true, main="example",freq=f)
Comments
Post a Comment