Monday, February 16, 2009

use mtext() to label sub graph

windows(10, 4)
ll = matrix(c(1:3), nrow=1, byrow=TRUE)
width = c(0.4, 0.4, 0.2);
height = c(1);
layout(ll, width, height);
par(mar=c(4, 4, 2, 1));
cols <- c("green", "blue", "red")

plot(0, type="n", ylim=c(0, 1), xlim=c(0, 10), main=expression("type A"), xlab="Time (hr)",
ylab="log2(expr)", axes = FALSE);
axis(1, 1:10, (1:10)*12, cex.axis=0.7)
axis(2)
for(i in 1:3){
lines(1:10, sort(runif(10)), type = "b", col = cols[i], lty = 1, lwd=2, pch=i);
}
box();
mtext("A", at= -1, line = 0.8);

plot(0, type="n", ylim=c(0, 1), xlim=c(0, 10), main=expression("type B"), xlab="Time (hr)",
ylab="log2(expr)", axes = FALSE);
axis(1, 1:10, (1:10)*12, cex.axis=0.7)
axis(2)
for(i in 1:3){
lines(1:10, sort(runif(10)), type = "b", col = cols[i], lty = 1, lwd=2, pch=i);
}
box();
mtext("B", at= -1, line = 0.8);

genelist <- c("AA", "BB", "CC")
par(mar=c(4, 0, 2, 0));
plot(0, type="n", ylim=c(9, 14), xlim=c(0, 9), xlab="", ylab="", axes = FALSE);
legend("topleft", genelist, col=cols, lty=1, cex=0.9, lwd=2, pch=1:3, box.lwd = 0 , box.lty = 0)

---------------------------------------------

No comments: