Histogram with Logarithmic Scale and custom breaks

A histogram is a poor-man’s density estimate. Note that in your call to hist() using default arguments, you get frequencies not probabilities — add ,prob=TRUE to the call if you want probabilities.

As for the log axis problem, don’t use ‘x’ if you do not want the x-axis transformed:

plot(mydata_hist$count, log="y", type="h", lwd=10, lend=2)

gets you bars on a log-y scale — the look-and-feel is still a little different but can probably be tweaked.

Lastly, you can also do hist(log(x), ...) to get a histogram of the log of your data.

Leave a Comment