[R] Y-axis range in histograms
Duncan Murdoch
murdoch.duncan at gmail.com
Mon May 31 17:01:53 CEST 2010
On 31/05/2010 10:49 AM, Aarne Hovi wrote:
> Hi,
>
> I'm trying to create a histogram with R. The problem is that the frequency
> is high for a couple of x-axis categories (e.g. 1500) and low for most of
> the x-axis categories (e.g. 50)
> http://r.789695.n4.nabble.com/file/n2237476/LK3_hist.jpg . When I create the
> histogram, it is not very informative, because only the high frequencies can
> be seen clearly. Is there any way I could cut the y-axis from the middle so
> that the y-axis values ranged for example from 0 to 300, and then again from
> 900 to 1500?
Using a bar chart like that takes away most of the value of using a bar
chart: you lose both area and length as visual clues to the value. Why
not do something different? For example,
x <- runif(1700) + rep(1:5, c(1500,50,55,45,50))
hist(x, breaks=5) # The one you don't like
h <- hist(x, breaks=5, plot=FALSE) # Get the data
plot(h$mids, h$counts, log="y") # Plot on a log scale
abline(v=h$breaks,col="lightgray") # Indicate the bins
Duncan Murdoch
More information about the R-help
mailing list