Skip to content

Using logarithmic y-axis (density) in a histogram

1 message · mwtoews at sfu.ca

#
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