Michael Friendly
2011-Jun-01 19:17 UTC
[R] weird error from MASS::eqcsplot with postscript driver
[Env: R 2.12.2, Win XP] I'm creating figures using MASS::eqcsplot to provide equal scaling of the axes. My figures work OK when I plot to the screen, but when I try to do the same plot as a postscript file, I get an unexplicable error, > figframe() Error in if (yuin > xuin * ratio) yuin <- xuin * ratio else xuin <- yuin/ratio : missing value where TRUE/FALSE needed > traceback() 2: eqscplot(x = 0, y = 0, xlim = xlim, ylim = ylim, xlab = xlab, ylab = ylab, type = "n") 1: figframe() > Here is a minimal source script exhibiting the problem: library(MASS) eps <- function(file="Rplot.eps", horizontal=FALSE, paper="special", ...) { postscript(file=file, onefile=FALSE, horizontal=horizontal, paper=paper, ...) } # Figure frame figframe <- function( xlim = c(-3,3), ylim = c(-3,3), xlab = '', ylab = '') { eqscplot( x=0,y=0, xlim = xlim, ylim = ylim, xlab = xlab, ylab = ylab, type = 'n') abline( v=0, col="gray") abline( h=0, col="gray") } # screen: OK op <- par(mar=c(3, 3, 1, 1) + 0.4) figframe() par(op) # eps: fails eps(file="test1.eps") op <- par(mar=c(3, 3, 1, 1) + 0.4) figframe() par(op) dev.off() I know this worked under an earlier version, probably ~ R 2.9.x -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
Rolf Turner
2011-Jun-01 21:08 UTC
[R] weird error from MASS::eqcsplot with postscript driver
The problem is the ``paper="special" '' specification in your eps() function. This makes par("pin"), which eqcsplot() uses in its calculations, undefined. The ``value'' thus produced is: [1] NaN NaN Which makes perfect sense if you think about it. If you're going to use paper=special, you need to specify "height" and "width". cheers, Rolf Turner On 02/06/11 07:17, Michael Friendly wrote:> [Env: R 2.12.2, Win XP] > > I'm creating figures using MASS::eqcsplot to provide equal scaling of > the axes. My figures work OK > when I plot to the screen, but when I try to do the same plot as a > postscript file, I get an > unexplicable error, > > > figframe() > Error in if (yuin > xuin * ratio) yuin <- xuin * ratio else xuin <- > yuin/ratio : > missing value where TRUE/FALSE needed > > traceback() > 2: eqscplot(x = 0, y = 0, xlim = xlim, ylim = ylim, xlab = xlab, > ylab = ylab, type = "n") > 1: figframe() > > > > Here is a minimal source script exhibiting the problem: > > library(MASS) > > eps <- function(file="Rplot.eps", horizontal=FALSE, paper="special", > ...) { > postscript(file=file, onefile=FALSE, horizontal=horizontal, > paper=paper, ...) > } > > > # Figure frame > figframe <- function( xlim = c(-3,3), ylim = c(-3,3), xlab = '', ylab > = '') { > eqscplot( x=0,y=0, xlim = xlim, ylim = ylim, xlab = xlab, ylab = > ylab, type = 'n') > abline( v=0, col="gray") > abline( h=0, col="gray") > } > > # screen: OK > op <- par(mar=c(3, 3, 1, 1) + 0.4) > figframe() > par(op) > > # eps: fails > eps(file="test1.eps") > op <- par(mar=c(3, 3, 1, 1) + 0.4) > figframe() > par(op) > dev.off() > > I know this worked under an earlier version, probably ~ R 2.9.x >