Hi,
Have you looked at the documentation at http://had.co.nz/ggplot2/ ?
You will find the answers to your questions there.
On Wed, Aug 24, 2011 at 7:46 AM, ashz <ashz at walla.co.il>
wrote:> Hi,
>
> Based on some modification that I did to the R Cookbook Graphs Scatterplots
> code, link:http://wiki.stdout.org/rcookbook/Graphs/Scatterplots%20(ggplot2)
>
> I have some questions and I will appreciate a help:
> - ? ? ? How do I change the legend title?
See the scales documentation on the website.
> - ? ? ? How can I change the for each linear regression its color and
linetype?
See the geom_smooth documentation on the website.
> - ? ? ? How can I add for both the linear regression lines their equations
and
> Rseq inside or below the plot?
see ?annotate
Best,
Ista
>
> Code:
> set.seed(955)
> df <- data.frame(cond = rep(c('A', 'B'), each=10),
> ? ? ? ? ? ? ? ? xvar = 1:20 + rnorm(20,sd=3),
> ? ? ? ? ? ? ? ? yvar = 1:20 + rnorm(20,sd=3))
>
> ggplot(df, aes(x=xvar, y=yvar, shape=cond)) +
> scale_shape_manual(values=c(1,2)) ?+
> ? ?geom_smooth(method = "lm", se=FALSE) +
> ? ? ? ? theme_bw()+
> ? ? ? ? geom_point(size = 5)+
> ? ? ? ? opts(title = "Xvar vs. Yvar",
> ? ? ? ? ?plot.title = theme_text(face="bold", size=16),
> ? ? ? ? ?axis.text.x ?= theme_text(angle=90),
> ? ? ? ? ?axis.title.x = theme_text(face="bold", size=12),
> ? ? ? ? ?axis.title.y = theme_text(face="bold", size=12,
angle=90),
> ? ? ? ? ?panel.grid.major = theme_blank(), # switch off major gridlines
> ? ? ? ? ?panel.grid.minor = theme_blank()
> ?)
>
> Thanks a lot in advance
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/Scatter-plots-linear-regression-in-ggplot2-tp3765080p3765080.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.
>
--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org