Legends in ggplot2
[This article was first published on Shige's Research Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
A simple plot takes a few lines of coding:Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
g1 <- ggplot(d, aes(birth.year))
g2 <- g1 + geom_line(aes(y=alive0, linetype="Famale")) +
geom_line(aes(y=alive1, linetype=”Male”)) + scale_linetype_discrete(name = “”)
g3 <- g2 + geom_point(aes(y=alive0, shape="Famale")) +
geom_point(aes(y=alive1, shape=”Male”)) + scale_x_continuous(“”) + scale_y_continuous(“Proportion Alive in 1982″) + opts(legend.position=c(.24, .95), legend.justification = c(1, 1)) + scale_shape_discrete(name=””)
g4 <- g3 + labs(fill="")
To leave a comment for the author, please follow the link and comment on their blog: Shige's Research Blog.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.