autumnlin
2012-Oct-19 15:46 UTC
[R] how can i plot dotted regression line shaped with condition using ggplot
I am plotting ggplot smooth line. I would like to add dots to the regression line, the dots are shaped under different condition. p <- ggplot(data, aes(x = x, y = y, shape = assign, linetype = factor(sex))) p0b <- p+ scale_linetype_manual(breaks=c("0","1"), values=c(1,2)) + geom_smooth(aes(shape = assign, linetype = female), method = "lm", se FALSE, size = 1.2) the dots on the smooth line should be shaped by assign. how can i do it? maybe i should add something like scale_shape_manual(values=c(17, 0, 19)) and whatelse? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/how-can-i-plot-dotted-regression-line-shaped-with-condition-using-ggplot-tp4646773.html Sent from the R help mailing list archive at Nabble.com.
Ista Zahn
2012-Oct-19 17:41 UTC
[R] how can i plot dotted regression line shaped with condition using ggplot
I may be missing something, but if you want dots you need to ask for them with geom_point() Best, Ista On Fri, Oct 19, 2012 at 11:46 AM, autumnlin <jialincau at gmail.com> wrote:> I am plotting ggplot smooth line. I would like to add dots to the regression > line, the dots are shaped under different condition. > > p <- ggplot(data, aes(x = x, y = y, > shape = assign, linetype = factor(sex))) > > p0b <- p+ > scale_linetype_manual(breaks=c("0","1"), values=c(1,2)) + > geom_smooth(aes(shape = assign, linetype = female), method = "lm", se > FALSE, size = 1.2) > > the dots on the smooth line should be shaped by assign. how can i do it? > maybe i should add something like > scale_shape_manual(values=c(17, 0, 19)) > and whatelse? > Thanks. > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-can-i-plot-dotted-regression-line-shaped-with-condition-using-ggplot-tp4646773.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.
autumnlin
2012-Oct-19 19:48 UTC
[R] how can i plot dotted regression line shaped with condition using ggplot
I would like to add specific point on to the regression line, like (x=1),shape=value(1) is it possible? -- View this message in context: http://r.789695.n4.nabble.com/how-can-i-plot-dotted-regression-line-shaped-with-condition-using-ggplot-tp4646773p4646797.html Sent from the R help mailing list archive at Nabble.com.
Ista Zahn
2012-Oct-19 21:23 UTC
[R] how can i plot dotted regression line shaped with condition using ggplot
See ?annotate for help on adding individual points/labels/etc to a plot. Best, Ista On Fri, Oct 19, 2012 at 3:48 PM, autumnlin <jialincau at gmail.com> wrote:> I would like to add specific point on to the regression line, like > (x=1),shape=value(1) > is it possible? > > > > -- > View this message in context: http://r.789695.n4.nabble.com/how-can-i-plot-dotted-regression-line-shaped-with-condition-using-ggplot-tp4646773p4646797.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > 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.