[R] behavior of squishplot in TeachingDemos

Greg Snow Greg.Snow at imail.org
Wed Mar 4 18:26:52 CET 2009


Thank you for finding this.  Yes in some cases the parameter settings need to be updated by a call to plot.new for the calculations to be correct (if you carried out your example 2 more times you would see that the 3rd plot is also incorrect since it is still using the dimensions of the 2nd plot in the calculations).

I have added a call to plot.new inside of the squishplot function for the next version, but until that comes out (I have been meaning to get it out for a while, but don't have a specific time frame) the work around that you found of calling plot.new before squishplot is the best thing to do.

Thanks,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Stephen Tucker
> Sent: Tuesday, March 03, 2009 9:17 AM
> To: r-help at r-project.org
> Subject: [R] behavior of squishplot in TeachingDemos
> 
> 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
> 
> ______________________________________________
> 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.




More information about the R-help mailing list