[R] plotting a grid with color on a map

Jim Lemon jim at bitwrit.com.au
Wed May 13 14:09:25 CEST 2009


It was the NAs that fooled color2D.matplot. This gets your colors, 
although not exactly what you want. Look at the help for color2D.matplot 
to get that. I think fiddling with the x and y limits on the map() call 
will get the positions right.

temp1<-read.table("time1test.dat",header=TRUE)
library(plotrix)
# reverse the row order, as color2D.matplot reverses it
color2D.matplot(temp1[36:1,],c(0.5,1),c(0.5,0),c(1,0),axes=FALSE)
# don't erase the above plot
par(new=TRUE)
# do a "ghost" plot with just the axes
plot(0,xlim=maplim[1:2],ylim=maplim[3:4],type="n")
# add the map on top in black
map(add=TRUE,col="black")

Jim




More information about the R-help mailing list