I'm generating a composite graph in R which I've set up as 2x2. For the figures, I have 3 boxplots and would like for the last quadrant to contain some descriptive text about the graphs. A bit of Google-ing led me to create an empty plot with plot.new() and then use the plotrix package which allows me to build a table and put that into the graph. An example is below, along with some pseudo-code. The data and the actual figures in the pseudo-code are irrelevant - just placeholders to get to what I'm trying to accomlish.
The problem is that this isn't very attractive and I can't find any other way to create a block of text to occupy that last quadrant. I've tried changing the x and y coordinates for the table, which doesn't work since there are technically no coordinates in an empty plot other than 0,0. I've also tried increasing the font size with cex=##, but that just makes the lines run together.
Any tips are appreciated.
library('beeswarm')
library('plotrix')
d = data.frame('study' = c(rep('study1',25),rep('study2',25)))
d$res1 = c(rnorm(25,40,5),rnorm(25,50,10))
d$category = c(rep('yes',12),rep('no',13),rep('yes',13),rep('no',12))
opar = par(mfrow=c(2,2))
rng = range(d$res)
study1 = which(d$study == 'study1')
boxplot(d$res1[study1]~d$category[study1], pch=19, lwd=2, cex=1.5, outline=F, ylim=rng, main='Study 1')
beeswarm(d$res1[study1]~d$category[study1], pch=19, cex=1.5, col=c('red','blue'), add=T)
boxplot(d$res1[-study1]~d$category[-study1], pch=19, lwd=2, cex=1.5, outline=F, ylim=rng, main='Study 2')
beeswarm(d$res1[-study1]~d$category[-study1], pch=19, cex=1.5, col=c('red','blue'), add=T)
shps = rep(17,length(d$study))
shps[study1] = 19
boxplot(d$res1~d$category, pch=46, lwd=2, cex=1.5, outline=F, ylim=rng, main='Combined')
beeswarm(d$res1~d$category, pch=46, cex=1.5, col=c('red','blue'), add=T, pwpch=shps)
legend('topright',c('Study 1','Study 2'), pch=c(19,17), pt.cex=1.5)
plot.new()
tbldf = data.frame('p-value' = c(0.33,0.40,0.85),
'FDR' = c(0.84, 0.96, 0.97))
rownames(tbldf) = c('Study 1', 'Study 2', 'Combined')
addtable2plot(0, 0, tbldf, bty = "o", display.rownames = TRUE,
title = sprintf('Analyte'), vlines=T, cex=1.25)
par(opar)
What I get is something like this:
What I would like is more like this - the table is still a bit 'boring' but adequate for the purpose. Any improvements are welcome: