[R] Substitute for xlim and usr in boxplot(...) & bxp(...)?

Mark Van De Vyver mvdv at spamcop.net
Thu Mar 18 01:34:07 CET 2004


Hi Marc, 
As you guessed my current point is like your second example.  I actually
have three groups of three, so the normal box plot drws them at positions,
1:9 by the time I've placed them where I'd like they plot at positions
(roughly) 1:8, leaving me with a large right hand space that I'd like to get
rid of.....

I think your code will work :)  I've not seen the mixing of plot and boxplot
before, so I'll have to play for a while..
Thanks again
Mark

> -----Original Message-----
> From: Marc Schwartz [mailto:MSchwartz at MedAnalytics.com] 
> Sent: Thursday, March 18, 2004 10:41 AM
> To: Mark Van De Vyver
> Cc: 'R-Help'
> Subject: Re: [R] (no subject)
> 
> 
> On Wed, 2004-03-17 at 16:32, Mark Van De Vyver wrote:
> > Hi Marc,
> > Thanks for the response.  Apologies for the lack of 
> detail... I have 
> > used 'boxwex', 'at' and ylim, to place things nicely, except I know 
> > have some spare room at the end of the plot, which I would 
> like to get 
> > rid of.... Your suggestion to use 'add' per the example is 
> one I had 
> > not thought of.  Does any one know of a simpler approach, 
> to use add 
> > I'm need to create two boxplots, a dummy (with x taking the correct 
> > range of values, say boxplot(1:10, ylim = c(0, 100))) and 
> the real box 
> > plot with, say 11 box plots...
> > 
> > Thanks again
> > Mark
> 
> 
> Mark,
> 
> I am perhaps still a bit confused. Do you have 11 'unrelated' 
> groups of data or is it perhaps 5 pairs (10 total) plus one 
> additional that is separate and off by itself?
> 
> If it is 11 separate groups, they should space evenly across 
> the x axis based upon the default way boxplot() handles such 
> things. The x axis positions will be 1:11, with the same 
> amount of space on the left and right hand sides of the plot.
> 
> For example:
> 
> # Create a 11 column dataframe
> x <- data.frame(matrix(rnorm(50 * 11), ncol = 11))
> 
> # Do the default boxplot
> boxplot(x)
> 
> 
> 
> On the other hand, if you perhaps have the second scenario of 
> 5 pairs and a separate single, you could do something like 
> the following:
> 
> # Create a plot window with x from 0.5 to 6.5 and y 
> reflecting the # range of values in 'x' plot(c(0.5, 6.5), 
> range(x), type = "n", ann = FALSE, axes = FALSE)
> 
> # Now add boxplots for the 'odd' columns in 'x', adding the 
> 11th # column. Set the 'at' values to pair up the first 5 
> cols and # plot the 11th column at x = 6.2 for symmetry. 
> boxplot(x[, c(1, 3, 5, 7, 9, 11)], at = c(1:5 - 0.2, 6.2), 
>         boxwex = 0.2, add = TRUE, xaxt = "n")
> 
> # Now add boxplots for the 'even' columns in 'x'
> # Set the 'at' values to pair these up with the above 
> boxplot(x[, c(2, 4, 6, 8, 10)], at = 1:5 + 0.2, 
>         boxwex = 0.2, add = TRUE, xaxt = "n")
> 
> Not sure if that is what you are looking for, but it might 
> provide some food for thought.
> 
> HTH,
> 
> Marc Schwartz
> 
>




More information about the R-help mailing list