Impact of cex changing as a function of mfrow
Duncan Perhaps I did not explain sufficiently -- the code that I sent makes the correction in FINDCEX. But, that correction does not accomplish the intended goal -- as evidenced by the graphic that is created from the code that I sent. The option of "brute force" would require trial and error. I was hoping that invoking some other option in mtext, such as padj, would accomplish my goal of needing only to multiply the line= value by the value returned from my function. Dennis Dennis Fisher MD P < (The "P Less Than" Company) Phone: 1-866-PLessThan (1-866-753-7784) Fax: 1-866-PLessThan (1-866-753-7784) www.PLessThan.com
On Sep 2, 2012, at 11:43 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
On 12-09-02 1:40 PM, Dennis Fisher wrote:
R 2.15.1 OS X (MLion) Colleagues, I am aware that changes in mfrow / mfcol in par() affect cex (from help: In a layout with exactly two rows and columns the base value of ?"cex"? is reduced by a factor of 0.83: if there are three or more of either rows or columns, the reduction factor is 0.66). I generate a multipage PDF in which mfrow varies such that cex is impacted. This affect mtext in the outer margin. Sample code is pasted at the bottom of this email. The impact is most obvious if one examines the text at the bottom of each page as one moves page-to-page. Does anyone have a suggestion for how to overcome this (other than using brute force).
I am not sure what's wrong with brute force here. You know the formula for the reduction; just apply a corresponding increase first. Duncan Murdoch
Dennis
Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
# In a layout with exactly two rows and columns the base value of ?"cex"? is reduced by a factor of 0.83: if
# there are three or more of either rows or columns, the reduction factor is 0.66.
FINDCEX <- function()
{
CORRECT <- 1
MFROW <- par()$mfrow
MFCOL <- par()$mfcol
TEST <- all(MFROW == MFCOL)
if (TEST && MFROW == c(2,2)) CORRECT <- 1 / 0.83
if (TEST && (MFROW[1] >= 3 | MFROW[2] >= 3)) CORRECT <- 1 / 0.66
if (!TEST) cat("MFROW does not equal MFCOL\n")
cat(MFROW, CORRECT, "\n")
return(CORRECT)
}
pdf("TestCEX.pdf", 8, 6)
par(mfrow=c(1,1), omi=c(1,1,1,1))
plot(1)
mtext(outer=T, side=1, line=0, cex=1, "line 0")
mtext(outer=T, side=1, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=3, line=0, cex=1, "line 0")
mtext(outer=T, side=3, line=1, cex=1, "line 1")
mtext(outer=T, side=2, line=0, cex=1, "line 0")
mtext(outer=T, side=2, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=4, line=0, cex=1, "line 0")
mtext(outer=T, side=4, line=1, cex=1, "line 1")
par(mfrow=c(1,2), omi=c(1,1,1,1))
plot(1)
mtext(outer=T, side=1, line=0, cex=1, "line 0")
mtext(outer=T, side=1, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=3, line=0, cex=1, "line 0")
mtext(outer=T, side=3, line=1, cex=1, "line 1")
mtext(outer=T, side=2, line=0, cex=1, "line 0")
mtext(outer=T, side=2, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=4, line=0, cex=1, "line 0")
mtext(outer=T, side=4, line=1, cex=1, "line 1")
par(mfrow=c(2,2), omi=c(1,1,1,1))
plot(1)
mtext(outer=T, side=1, line=0, cex=1, "line 0")
mtext(outer=T, side=1, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=3, line=0, cex=1, "line 0")
mtext(outer=T, side=3, line=1, cex=1, "line 1")
mtext(outer=T, side=2, line=0, cex=1, "line 0")
mtext(outer=T, side=2, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=4, line=0, cex=1, "line 0")
mtext(outer=T, side=4, line=1, cex=1, "line 1")
par(mfrow=c(3,3), omi=c(1,1,1,1))
plot(1)
mtext(outer=T, side=1, line=0, cex=1, "line 0")
mtext(outer=T, side=1, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=3, line=0, cex=1, "line 0")
mtext(outer=T, side=3, line=1, cex=1, "line 1")
mtext(outer=T, side=2, line=0, cex=1, "line 0")
mtext(outer=T, side=2, line=FINDCEX(), cex=1, "line FINDCEX")
mtext(outer=T, side=4, line=0, cex=1, "line 0")
mtext(outer=T, side=4, line=1, cex=1, "line 1")
graphics.off()
system("open TestCEX.pdf")
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.