Re: [R] Y-axis range in histograms

From: Duncan Murdoch <>
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)
> . 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 mailing list PLEASE do read the posting guide 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 Please read the posting guide before posting to the list.

list of date sections of archive