Putting Text in a Margin

May 10, 2010
By

(This article was first published on R-Chart, and kindly contributed to R-bloggers)

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 his blog: R-Chart.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags:

Comments are closed.