[R] Using logarithmic y-axis (density) in a histogram

Michael Toews mwtoews at sfu.ca
Thu Mar 8 18:50:48 CET 2007


You might also want to try "density", since it can theoretically have 
non-zero bins, since it doesn't use "bins". For example, take a Weibull 
distribution, which could look better with a log y-axis:

x <- rweibull(1000,1,5)
par(mfrow=c(2,1))
plot(density(x,from=0))
rug(x)
plot(density(x,from=0),log="y")
rug(x)

you may need to fiddle with the "bw" (bandwidth) parameter of "density", 
since this controls the smoothness of the kernel (see ?density).
+mt



More information about the R-help mailing list