Thursday, September 01, 2011

Density curve of histogram plot in R

Ref: http://casoilresource.lawr.ucdavis.edu/drupal/book/export/html/23 


To add density curve on a histogram, like the green curve above, use code below:


#plot the distribution
hist(slope, breaks=1000, freq=F, main=main, xlab="Slope Value (percent)", xlim=c(0,150), ylim=c(0,.05) )
lines(density(slope, bw=1), col="green")

No comments:

Post a Comment