[R] Controlling size of boxplot when it is added in a plot
Charilaos Skiadas
skiadas at hanover.edu
Sun Jan 14 05:12:00 CET 2007
Greetings,
I am trying to add a boxplot to the bottom of a histogram, right
between the histogram bars and the x axis. Here is the code I am
using at the moment (the par line is probably not relevant for our
discussion):
hs <- hist(x, breaks = 20, plot = F)
par(mar = c(3,3,2,1))
hist(x, breaks = 20, main = NULL, ylim = c(-2, max(hs$counts)))
boxplot(x, horizontal = T, axes = T, add = T, at = -1)
The problem is the following. As it is, the boxplot restricts itself
to the -1 line. I would like it to occupy both the -1 and the -2
lines ( I guess more generally I would like to control how much
vertical space the "embedded boxplot" occupies). I tried to set the
width parameter in the boxplot, but that seemed to have no effect at
all.
On an OT note, I haven't seen this way of combining a histogram with
a boxplot (perhaps I haven't looked really hard). I thought it would
be useful for my students to see them next to each other, to develop
a feeling for what histograms might correspond to what boxplots. Is
there perhaps some reason why I should avoid showing those graphs to
them like that, that I am not aware of? Or just a reason why I
haven't seen them combined like this much?
TIA
Charilaos Skiadas
Department of Mathematics
Hanover College
P.O.Box 108
Hanover, IN 47243
More information about the R-help
mailing list