Skip to content
Prev 111053 / 398498 Next

Using logarithmic y-axis (density) in a histogram

On 3/8/2007 8:10 AM, david.bolius at art.admin.ch wrote:
I'd say from a graphical perspective it doesn't make sense to use a bar 
chart for a histogram on a log scale (where should the base of the bars 
go?), but if you really want to, you could do it by calling hist() with 
plot=FALSE, and building it yourself using the "histogram" object that 
is returned.  For example,

x <- rnorm(10000)
h <- hist(x, breaks="Scott", plot=FALSE)
plot(h$mids, h$density, log="y", type='b')

Duncan Murdoch