[R] ggplot: dodge positions

Thaler,Thorn,LAUSANNE,Applied Mathematics Thorn.Thaler at rdls.nestle.com
Mon Jul 2 12:55:57 CEST 2012


Yes indeed. Sorry for the typo, I just added the library(ggplot) thing afterwards and I did not check for the spelling. So it should read as library(ggplot2) and there the issue is still unsettled.

Thx for pointing that out.

KR,

-Thorn

> -----Original Message-----
> From: Rui Barradas [mailto:ruipbarradas at sapo.pt]
> Sent: Montag, 2. Juli 2012 12:20
> To: Thaler,Thorn,LAUSANNE,Applied Mathematics
> Cc: r-help at r-project.org
> Subject: Re: [R] ggplot: dodge positions
> 
> Hello,
> 
> Though I'm not the most fluent user of ggplot, I've seen no problem
> with
> the graph, each subgroup of points is over each boxplot.
> 
> Maybe what made the difference was the use of --->  ggplot2
> not ggplot.
> 
> Hope this helps,
> 
> Rui Barradas
> 
> Em 02-07-2012 10:43, Thaler,Thorn,LAUSANNE,Applied Mathematics
> escreveu:
> > Dear all,
> >
> > I want to get a series of boxplots (grouped by two factors) and I
> want to overlay the original observations and the following code does
> almost what I want:
> >
> > library(ggplot)
> > ddf <- data.frame(x=factor(rep(LETTERS[1:4], each=30)), y =
> runif(120,0,10), grp = factor(rep(rep(1:3, 10), 4)))
> > ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() + geom_point()
> >
> > Yet the position of the points and the position of the boxes on the
> x-axis is not the same. I would like that the points are shifted
> accordingly, such that they line up with the boxplots. I tried
> position_dodge:
> >
> > ggplot(ddf, aes(x, y, colour=grp)) + geom_boxplot() +
> geom_point(aes(ymax=max(y)), position = position_dodge(width=.75))
> >
> > but that did not really help, as all points are now dodged and I just
> want to have a fixed offset for each subgroup of points such that the
> boxplot and the points are aligned. Any ideas?
> >
> >
> > Kind Regards,
> >
> > Thorn Thaler
> > Mathematician
> >
> > Applied Mathematics
> > Nestec Ltd,
> > Nestlé Research Center
> > PO Box 44
> > CH-1000 Lausanne 26
> > Phone: +41 21 785 8220
> > Fax: +41 21 785 9486
> >
> > ______________________________________________
> > R-help at r-project.org 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.
> >
> 



More information about the R-help mailing list