From racinej at mcmaster.ca  Wed Oct 22 23:50:12 2008
From: racinej at mcmaster.ca (racinej at mcmaster.ca)
Date: Wed, 22 Oct 2008 23:50:12 +0200 (CEST)
Subject: [Rd] Potential improvement to boxplot when outline=FALSE is set?
	(PR#13196)
Message-ID: <20081022215012.81CF3282EF48@mail.pubhealth.ku.dk>

Hi.

I have recently noticed that when using boxplot with outline=FALSE, the
default ylim (xlim if horizontal=TRUE) might be improved on. The default
can result in much wasted display and hard to read plots. A simple
snippet of test code is given below that illustrates the issue along
with a suggested improvement.

Thanks ever so much for your wonderful and ongoing contributions to the
open source community.

## Demonstration code to illustrate that when outline=FALSE in
## boxplots, ylim (or xlim when horizontal=TRUE is set) might be
## better set.

set.seed(12345)
x <- rchisq(10000,df=1)
par(mfrow=c(2,1))
## Default wastes much graphics display space...
boxplot(x,outline=FALSE)
## This simple modification can rectify the situation...
ylim=c(max(min(x),quantile(x,.25)-1.5*IQR(x)),
  min(max(x),quantile(x,.75)+1.5*IQR(x)))
boxplot(x,outline=FALSE,ylim=ylim)

## End of demonstration code

Note that when using lists, the one would compute, say,
max(min(x),quantile(x,.25)-1.5*IQR(x)) for each element of the list and
take the minimum over each of these to get the lower bound for ylim
(xlim if horizontal=FALSE).

Thanks for giving this your consideration.

-- Jeff


-- 
Professor J. S. Racine         Phone:  (905) 525 9140 x 23825
Department of Economics        FAX:    (905) 521-8232
McMaster University            e-mail: racinej at mcmaster.ca
1280 Main St. W.,Hamilton,     URL:
http://www.economics.mcmaster.ca/racine/
Ontario, Canada. L8S 4M4

`The generation of random numbers is too important to be left to chance'



[Rd] Potential improvement to boxplot when outline=FALSE is set? (PR#13196)
racinej at mcmaster.ca