Hi > -----Original Message----- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- > project.org] On Behalf Of Ben Bolker > Sent: Wednesday, September 11, 2013 3:46 PM > To: r-h...@stat.math.ethz.ch > Subject: Re: [R] superpose violin and boxplot in ggplot > > PIKAL Petr <petr.pikal <at> precheza.cz> writes: > > > > > Dear all > > > > I am struggling a bit with tricky violinplot. I found how to > superpose > boxplots correctly to violinplots. > > > > p<-ggplot(Cars93, aes(x=Origin, y=Price, fill=Type, colour=Type)) > > [snip] > > > > How I could change colour of boxplots to single colour but get the > > boxes at the correct locations e.g. over violins. > > > > Thanks > > Petr > > > > > > Use the group() aesthetic: > > p+geom_violin()+ > p+geom_boxplot(aes(fill=NULL,group=interaction(Type,Origin)), > position=position_dodge(width=.9), width=.5, colour="black")
Thanks. In the meantime I found another solution using scale_colour_manual. p+geom_violin()+geom_boxplot(aes(fill=NULL), position=position_dodge(width=.9), width=.5)+scale_colour_manual(values=rep("black", 6)) Your solution seems to be better as the legend looks slightly better. > > By the way, it would be useful to remind us that Cars93 is available in > the MASS package -- I had to hunt around a little bit. Sorry for that. I forgot to add it to my question together with ggplot2 package. Regards Petr > > ______________________________________________ > R-help@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. ______________________________________________ R-help@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.