Putting Text in a Margin
[This article was first published on R-Chart, 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.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I found text and title early on but was initially confounded when trying to add text outside of an actual chart. As it turns out, I needed to understand a bit about R’s concept of margins in a chart
> par(oma=c(2,2,2,2))
> plot(rnorm)
> mtext(‘The label’,EAST<-4, line=0.4, cex=1.2, col="red", outer=TRUE)
The first line uses the par command’s oma argument to provide the size of the outer margins in lines of text. The second line plots some data, and the last line places a label on the right side of the chart. See this post for more information about graphics parameters that deal with margins.
To leave a comment for the author, please follow the link and comment on their blog: R-Chart.
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.