[R] ggplot2: modifying line width and background fill color for stat_smooth()
John Kane
jrkrideau at inbox.com
Fri Mar 8 18:09:56 CET 2013
Is this roughly what you want? Shamelessly stolen , I mean , adapted from http://docs.ggplot2.org/0.9.3/stat_smooth.html
donner<-read.csv("http://www.ling.upenn.edu/~joseff/data/donner.csv")
ggplot(donner, aes(AGE, NFATE, colour = GENDER))+
geom_point(position = position_jitter(height = 0.02, width = 0)) +
stat_smooth(method = "glm", family = binomial, formula = y ~ poly(x,2),
alpha = 0.1, size=2, aes(fill = GENDER))
John Kane
Kingston ON Canada
> -----Original Message-----
> From: friendly at yorku.ca
> Sent: Fri, 08 Mar 2013 11:36:36 -0500
> To: r-help at r-project.org
> Subject: [R] ggplot2: modifying line width and background fill color for
> stat_smooth()
>
> In the example below, from
> http://www.ling.upenn.edu/~joseff/rstudy/summer2010_ggplot2_intro.html
>
> I'd like to make (a) the fitted line thicker and (b) change the
> background fill color for the confidence
> envelope around each fitted line to a low-alpha transparent version of
> the same color used
> for the separate fitted lines for GENDER, rather than grey for both.
> How can I do this?
>
> donner<-read.csv("http://www.ling.upenn.edu/~joseff/data/donner.csv")
>
> ggplot(donner, aes(AGE, NFATE, color = GENDER))+
> geom_point(position = position_jitter(height = 0.02, width = 0)) +
> stat_smooth(method = "glm", family = binomial, formula = y ~
> poly(x,2))
>
> For the line width, I tried,
>
> ggplot(donner, aes(AGE, NFATE, color = GENDER))+
> geom_point(position = position_jitter(height = 0.02, width = 0)) +
> stat_smooth(aes(size=2), method = "glm", family = binomial, formula =
> y ~ poly(x,2))
>
> This worked, but gave a spurious component labeled "2" in the plot
> legend.
>
> TIA,
> -Michael
>
> --
> Michael Friendly Email: friendly AT yorku DOT ca
> Professor, Psychology Dept. & Chair, Quantitative Methods
> York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
> 4700 Keele Street Web: http://www.datavis.ca
> Toronto, ONT M3J 1P3 CANADA
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!
More information about the R-help
mailing list