Re: [R] Controlling size of boxplot when it is added in a plot

From: Charilaos Skiadas <skiadas_at_hanover.edu>
Date: Sun 14 Jan 2007 - 21:33:54 GMT

Sorry, meant to send this to the list.

On Jan 14, 2007, at 4:28 PM, Charilaos Skiadas wrote:

> On Jan 14, 2007, at 5:50 AM, Chuck Cleland wrote:
>
>> Try setting the boxwex argument instead:
>
> Thanks Chuck, that does indeed seem to work pretty well. I'm not
> quite sure what the best way to determine an appropriate size for
> the boxplot would be, but the following kind of works, at least for
> the cases I tried. Though I'm not entirely happy with it. And I'm
> sure I've made a bunch of errors along the way, that someone more
> experienced in R could spot easily. Feel free to criticize the
> code. the boxwex default I guess is probably terribly named. One
> over it is supposed to be the size of the boxplot over the size of
> the histogram.
>
> force.odd <- function(x) {
> x + 1 - x %% 2;
> }
> boxhist <- function(x, boxwex = 8, ...) {
> hs <- hist(x, breaks = 20, plot = F)
> space <- force.odd(max(floor(hs$counts / boxwex), 1))
> plot(hs, main = NULL, ylim = c(-space, max(hs$counts)), ...)
> boxplot(x, horizontal = T, axes = T, add = T, at = -space/2,
> boxwex = space)
> }
> x <- rweibull(300,1,1); boxhist(x)
>
> Haris

Haris



R-help@stat.math.ethz.ch 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 Jan 15 08:39:30 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 15 Jan 2007 - 06:30:31 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.