[R] Impact of cex changing as a function of mfrow

Dennis Fisher fisher at plessthan.com
Sun Sep 2 19:40:46 CEST 2012


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).

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")



More information about the R-help mailing list