qoiqpwqr 发表于 2012-2-21 12:36 
先画出你要的大范围,然后用contour的add = T,把contour加上去
比如:
x
俺遇到的问题更为复杂,需要画好地图。请将site.xls先改写为site.csv存在R工作目录中才能运行下边的程序。
library("maps")
library("mapdata")
graphics.off()
data <- read.csv("site.csv",header=TRUE)
x <- data$Lat
y <- data$Long
NGEN <- data$NGEN
loess.NGEN <- loess(NGEN~x*y, degree=2, span=0.3, normalize=F, family="symmetric")
NGEN.marginal <- list(x=seq(min(x),max(x),0.1),y=seq(min(y),max(y),0.1))
predict.NGEN <- predict(loess.NGEN,expand.grid(NGEN.marginal))
tiff(file="NGEN.tif", width=85, height=72, units='mm',res=1200, compression='lzw', pointsize=5)
par(mar=c(6,7,1,1))
contour(NGEN.marginal$y, NGEN.marginal$x, t(predict.NGEN), levels=seq(4, 18, by=2), xlim=c(75, 134), ylim=c(19, 53), col="grey50", lwd=1, labcex=2, xlab="", ylab="", cex.lab=2, cex.axis=2)
mtext(expression(paste("Latitude (",degree,"N)")), side = 2, line = 4, cex = 2)
mtext(expression(paste("Longitude (",degree,"E)")), side = 1, line = 4, cex = 2)
map("china", add=TRUE, lwd=0.5, col="grey20")
contour(NGEN.marginal$y,NGEN.marginal$x,t(predict.NGEN),levels=seq(4, 18, by=2), xlim=c(75, 134), ylim=c(19, 53), col="grey5", lwd=1, labcex=2, xlab="", ylab="", cex.lab=2, cex.axis=2, add=TRUE)
mtext(expression(paste("Latitude (",degree,"N)")), side = 2, line = 4, cex = 2)
mtext(expression(paste("Longitude (",degree,"E)")), side = 1, line = 4, cex = 2)
dev.off