|
For
subtitles, you could use the following (assuming myfun() does the
plotting). mtext() could replace title() for more
control.
by(my.dat,
list(my.dat$agecat,my.dat$race),
FUN=function(x){
myfun(x)
title(sub = paste(x$agecat[1], x$race[1]))
})
For titles in the
outer margins, you could overplot a blank graph to set up axes and use text() to
put your categories in the margins.
Here's
an example for a plot I put together where I wanted placebo rates across the
tops and reduction due to treatment down the left side.
par(mfrow=c(1,1), omi=c(.25,.25, 0,
.25), new=T)
plot(1:4, 1:4, axes=F, xlab="",
ylab="", type="n")
text(1:4,
par('usr')[2]+3*par('cxy')[2], paste("Placebo Rate: ",
100*unique(simData$PlaceboRate), "%", sep=""), cex=.8, adj=.5)
text(par('usr')[1]-7*par('cxy')[1],
1:4, paste("Reduction: ", 100*rev(unique(simData$PercentReduction)), "%",
sep=""), cex=.8, adj=.5,
srt=90)
Of course, this is re-inventing the
wheel--Trellis handles this much more efficiently. You could put whatever
you have in myfun() into a panel function and let Trellis take care of the
details.
--Matt
I'm using the following code to
produce 16 plots arranged 4 x 4:
Ø
par(mfrow=c(4,4))
Ø
by(my.dat,list(my.dat$agecat,my.dat$race),FUN=function(x) myfun(x)) #myfun does a special
plot
I'd like to pass the "agecat" and "race" levels to the plots to identify
them. I guess ideally, I'd like the
index labels to run across the top and down the left side of the 4 x 4
plots. But passing the levels as
plot subtitles wouldn't be too bad.
Anyone have a tip for me?
Mike.
|