Hello My data looks ugly in a normal histogramm. How can I create a histogramm with a Y-axis in log-scale? Thanks for your help! David Graf --
On Fri, 2006-10-13 at 13:33 +0200, David Graf wrote:> Hello > > My data looks ugly in a normal histogramm. How can I create a > histogramm with a Y-axis in log-scale? > > Thanks for your help! > > David GrafI'm not sure that you want to use a log scale here, but may be better served by log transforming your data. For example: # Generate 100 random values from a log normal dist: x <- rlnorm(100) # Now do a histogram on x hist(x, freq = FALSE) # Now use log(x) hist(log(x), freq = FALSE) Does that help? Marc Schwartz
> My data looks ugly in a normal histogramm. How can I create a histogramm with a Y-axis in log-scale?It really doesn't make sense to have a logged y scale - because the bars on a histogram all start at zero (and all regions outside the support of the data have zero value) and logging 0 does not give something that is easily displayed on a plot! Hadley
On Fri, 13 Oct 2006, Marc Schwartz wrote:> On Fri, 2006-10-13 at 13:33 +0200, David Graf wrote: >> Hello >> >> My data looks ugly in a normal histogramm. How can I create a >> histogramm with a Y-axis in log-scale? >> >> Thanks for your help! >> >> David Graf >There is a log-histogram (called log.hist) in my package HyperbolicDist, and an updated one on my web page: http://www.stat.auckland.ac.nz/~dscott/Rpackage/NewFunctions/logHist.R David Scott _________________________________________________________________ David Scott Visiting (Until January 07) Department of Probability and Statistics The University of Sheffield The Hicks Building Hounsfield Road Sheffield S3 7RH United Kingdom Phone: +44 114 222 3908 Email: d.scott at auckland.ac.nz
Log y-axis on histograms are conceptually wrong, but aren't a bad idea either. It is conceptually safer to show this using "density". Consider an exponential distribution, which could look better with a log y-axis: x <- rexp(10000,.1) xd <- density(x,from=0) par(mfrow=c(2,1)) plot(xd) plot(xd,log="y",ylab="Log Density") Just use caution in the interpretation. The large dropping/osculating features on the right-hand side of the log plot are from sparse data-points, and this can be smoothed out by adjusting 'bw' to get a "theoretical" interpretation of the true distribution. +mt