Re: [R] Stripchart and Boxplots side-by-side

From: Karl Ove Hufthammer <>
Date: Thu, 22 May 2008 14:59:45 +0200

Dieter Wirz:

> with(InsectSprays, boxplot(count ~ spray, boxwex = 0.3))
> with(InsectSprays, stripchart(count ~ spray, col = "red", vertical =
> TRUE, add = TRUE))
> But the dots from the stripchart are plotted over the Boxes.
> Is there any possibility to have Stripchart and Boxplots side-by-side,
> i.e. to move boxplots and/or stripcharts a bit to the left or right?

It's likely *possible*, but I think it might look a bit confusing. Your original example is OK, but I propose you change the plotting function you use. The following looks pretty good to me, and much better than your original, IMHO.

g = ggplot(InsectSprays, aes(x=spray, y=count)) g + geom_boxplot() + geom_point(colour="red", position="jitter")

Image at:

Here I've used jittering to make all of the observations visible. You *did* notice that a lot of observations were overplotted in your original graph, right? ;-)

Another solution would be to create two graphs side by side, one boxplot and one stripchart.

Karl Ove Hufthammer

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 22 May 2008 - 13:04:15 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 22 May 2008 - 13:30:39 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive