[R] help with plotting a grid on levelplot

From: Jeff D. Hamann <jeff.hamann_at_forestinformatics.com>
Date: Wed 30 Mar 2005 - 11:16:42 EST


I'm trying to plot a grid over a levelplot

print( levelplot( var1.pred~x+y,

                 data=saw.pred,
                 aspect=mapasp(saw.pred),
                 col.regions=terrain.colors(80),
                 main=main) )

using the data...

> saw.pred

      x   y var1.pred var1.var sort
1     5   5 3.3761200 256.3363  saw
2    15   5 3.3884142 499.5695  saw
3    25   5 3.5394769 362.5490  saw
4    35   5 3.6386983 439.3200  saw
5    45   5 3.1866799 458.5570  saw
6    55   5 2.8838555 331.2363  saw
..blah...blah...blah...
15  145   5 0.8705088 256.3363  saw
16    5  15 3.1183053 455.3765  saw

17 15 15 3.2780465 443.1954 saw
18 25 15 3.7146268 435.1166 saw

which looks just fine. I know want to plot a grid such that the cells are grouped into 5x5 cells (or some other grid spacing) over the levelplot for a demonstration and I'm getting stuck when trying to modify my levelplot() call above to include the extra calls to panel.levelplot...

I've gotten this far,

## plot the results (10mx10m plot that's 150m x 200m) main=expression( paste( widehat(V)[saw], ", in ", m^3, ha^{-1} ) ) print( levelplot( var1.pred~x+y,

                 data=saw.pred,
                 aspect=mapasp(saw.pred),
                 main=main,
                 panel = function(x,y,z=var1.pred )
                 {
                   panel.levelplot( x=x, y=y, z=z,
                                   subscripts=1:nrow(saw.pred),
                                   col.regions=terrain.colors(80),
                                   )
                   panel.last=grid( 15, 20, lwd=2, lty="solid", 
col="black" )
                 }
                 ) )

and the legend does match the same colors as the levelplot and the grid isn't centered on the levelplot either.

Could someone give me some direction? I've stayed away from modifying the panel.XX args when I use lattice, and now I need help.

Thanks,
Jeff.

---
Jeff D. Hamann
Forest Informatics, Inc.
PO Box 1421
Corvallis, Oregon USA 97339-1421
541-754-1428
jeff.hamann@forestinformatics.com
www.forestinformatics.com

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Mar 30 11:23:38 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:57 EST