Hi Ben,
Just a few things to add.
First, the same phenomenon occurs when you use any character string as
the value of cex; there is nothing special about "*".
Second, you cannot get this phenomenon by trying to do something like
par(cex="*")
because the par function actually checks if the value is a nonnegative
number.
Finally, producing the different graphs is clearly occuring inside the
"plot.xy" function, although I have not yet caused R2.14 to hang. This
at least suggests a fix: make sure that plot.xy checks the type of the
cex argument in the same way that par does.
Kevin
#######################
xy <- xy.coords(1:10, 1:10)
plot(xy)
for(i in seq(100)) plot.xy(xy, "p", cex="*", col=i)
#######################
> sessionInfo()
R version 2.14.0 (2011-10-31)
Platform: x86_64-pc-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] png_0.1-3
loaded via a namespace (and not attached):
[1] tools_2.14.0
On 11/16/2011 3:38 PM, Ben Bolker wrote:
Someone inquired on StackOverflow about apparently non-deterministic
graphics behaviour in R. I noticed that they were using cex="*" and
discovered some potentially weird behavior.
On repeated runs of the same code I can get different PNGs. If I set
the number of runs high enough, I seem to be able to get R to hang.
If I do a single version plotting to an interactive graphics window I
can get the point sizes to jump around as I resize the window (someone
reported being able to reproduce that behaviour in the Windows GUI as well).
This is clearly a user error, but non-deterministic behaviour (and
hanging) are a little disturbing.
I haven't had a chance yet to try to dig in and see what's happening
but thought I would report to see if anyone else could reproduce/figure
it out.
Ben Bolker
########################
## n<- 100 ## hangs R
n<- 33
fn<- paste("tmp",seq(n),"png",sep=".")
for (i in seq(n)) {
png(fn[i])
plot(1:10,1:10,cex="*");
dev.off()
}
ff<- subset(file.info(fn),select=size)
ff<- ff[!duplicated(ff$size),,drop=FALSE]
table(ff$size)
require(png)
pngs<- lapply(rownames(ff),readPNG)
png.to.img<- function(x) matrix(rgb(x[,,1],x[,,2],x[,,3]),
nrow=dim(x)[1],ncol=dim(x)[2])
imgs<- lapply(pngs,png.to.img)
par(mfrow=c(2,2))
lapply(imgs,function(x) {
plot(0:1,0:1,type="n",ann=FALSE,axes=FALSE)
rasterImage(x,0,0,1,1)
})
#########################
sessionInfo()
R Under development (unstable) (2011-10-06 r57181)
Platform: i686-pc-linux-gnu (32-bit)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] glmmADMB_0.6.5 MASS_7.3-14 png_0.1-3
loaded via a namespace (and not attached):
[1] grid_2.15.0 lattice_0.19-33 nlme_3.1-102 tools_2.15.0
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel