[Rd] Potential improvement to boxplot when outline=FALSE is set? (PR#13196)

From: <racinej_at_mcmaster.ca>
Date: Wed, 22 Oct 2008 23:50:12 +0200 (CEST)


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.

-- 
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'

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu 23 Oct 2008 - 16:47:36 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 Thu 23 Oct 2008 - 19:31:27 GMT.

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

list of date sections of archive