# Re: [R] Y-axis range in histograms

From: Duncan Murdoch <murdoch.duncan_at_gmail.com>
Date: Mon, 31 May 2010 11:01:53 -0400

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

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Mon 31 May 2010 - 16:48:25 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 31 May 2010 - 16:50:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.