Applying smooth to part of a facetted plot

120 views
Skip to first unread message

Bill Harris

unread,
Jul 7, 2010, 3:03:53 PM7/7/10
to ggp...@googlegroups.com
I've got a facet_wrap() plot with ~42 facets. A few of those have only
one data point per facet; the rest have between a handful and a lot.

I'd like to smooth the data, probably with lm(), where it makes sense
(where there are multiple points). The simple facet_wrap() errors out.
Is there a subset-like command invocation to apply smooth to just the
pertinent facets? I've looked in the book and on the Web reference pages
and haven't found it yet.

Thanks,

Bill

Hadley Wickham

unread,
Jul 8, 2010, 1:33:11 AM7/8/10
to Bill Harris, ggp...@googlegroups.com
Hi Bill,

Which version of ggplot2 are you using? In the latest version
(0.8.8), you shouldn't have any problems. If you do, please provide a
small reproducible example.

Hadley

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

wooster

unread,
Feb 8, 2011, 6:40:30 AM2/8/11
to Hadley Wickham, ggp...@googlegroups.com

Hi - I have the same question as Bill .. and was wondering where this
thread was headed? I can plot 2 facets with either facet_grid or
facet_wrap, but only need a smooth line on one of my two facets ..
I've looked through the book and online and haven't worked out how to
do this.

I'm assuming that instead of calling "smooth" in the qplot, I should
do so after facet_wrap but am not sure exactly how to do so:
qplot(x=length, y=MLU, data=data, colour=level,
geom=c("point","smooth")) + facet_wrap( ~ corpus)

I only need the smooth on one of the two 'corpus' plots .. Please
help?!

many thanks, Andrew


On Jul 8 2010, 5:33 am, Hadley Wickham <had...@rice.edu> wrote:
> Hi Bill,
>
> Which version of ggplot2 are you using?  In the latest version
> (0.8.8), you shouldn't have any problems.  If you do, please provide a
> small reproducible example.
>
> Hadley
>
> On Wed, Jul 7, 2010 at 9:03 PM, Bill Harris
>
>
>
>
>
>
>
>
>
> <bill_har...@facilitatedsystems.com> wrote:
> > I've got a facet_wrap() plot with ~42 facets.  A few of those have only

> > one data point perfacet; the rest have between a handful and a lot.
>
> > I'd like tosmooththe data, probably with lm(), where it makes sense


> > (where there are multiple points).  The simple facet_wrap() errors out.

> > Is there a subset-like command invocation to applysmoothto just the

wooster

unread,
Feb 8, 2011, 3:24:06 PM2/8/11
to ggplot2
Reply all
Reply to author
Forward
0 new messages