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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -