Thursday, June 28, 2012

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

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)

No comments:

Post a Comment