Two tips: adding title for graph with multiple plots; add significance asterix onto a boxplot

June 28, 2012

(This article was first published on One Tip Per Day, and kindly contributed to R-bloggers)

I’ve not added tips for a while. Here is it for today:

1. How to add title for graph with multiple plots?

par(mfrow=c(1,2),oma = c(0, 0, 2, 0))
plot(1:10,  main=”Plot 1″)
plot(1:100,  main=”Plot 2″)
mtext(“Title for Two Plots”, outer = TRUE, cex = 1.5)

2. How to add text (e.g. asterix for significance) onto a boxplot?

boxplot(len ~ dose, data = ToothGrowth, outline=F)
text(x=2,y=max(boxplot.stats(ToothGrowth$len[ToothGrowth$dose==1])$stat), paste(“n”,sum(ToothGrowth$dose==1),sep=”=”), pos=3, offset=.2, cex=.8)

To leave a comment for the author, please follow the link and comment on their blog: One Tip Per Day. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, 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...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)