[R] behavior of squishplot in TeachingDemos

Stephen Tucker brown_emu at yahoo.com
Tue Mar 3 17:17:29 CET 2009


Hi list,
I wonder if anyone has had this experience with squishplot() in the TeachingDemos package. 

Taking the example from the ?image help page,

library(TeachingDemos)
x <- 10*(1:nrow(volcano))
y <- 10*(1:ncol(volcano))

layout(matrix(c(1,2,3,4),ncol=2,byrow=TRUE),height=c(2,1))
## 1st plot
op <- squishplot(range(x),range(y),1)
image(x, y, volcano, col = terrain.colors(100))
par(op)
## 2nd plot
op <- squishplot(range(x),range(y),1)
image(x, y, volcano, col = terrain.colors(100))
par(op)

The second plot comes out looking as expected, but the first plot is not squished in the desired proportions. I tried tracking the modifications to par('pin') and par('plt') in the function but gave up midway through in desire for haste - not sure what is going on but I did find that taking advantage of the behavior above, calling 
plot.new(); par(new=TRUE)
before the first plot makes things work as expected. So the full code would be

layout(matrix(c(1,2,3,4),ncol=2,byrow=TRUE),height=c(2,1))
## 1st plot
op <- squishplot(range(x),range(y),1)
plot.new()
par(new=TRUE)
image(x, y, volcano, col = terrain.colors(100))
par(op)
## 2nd plot
op <- squishplot(range(x),range(y),1)
image(x, y, volcano, col = terrain.colors(100))
par(op)

+++

I wonder if this behavior is not surprising? It is a great function overall though - thanks for the contribution.

Stephen




More information about the R-help mailing list