如何为某些纬度添加虚线?

时间:2014-07-01 14:29:44

标签: r raster levelplot

我想绘制一个可以从这里下载的文件:

代码:

bte1=read.table("C:\\z1-hovmoll-new.txt", header = T, sep = "")
idx <- seq(as.Date('2010-05-05'), as.Date('2012-12-25'), 'day')##966
dat1 <- expand.grid(y=bte1[,1], x=idx)
 RawData1 <- as.matrix(bte1[,-1])
 my.at<-seq(0,0.4,0.01)

# Warning; the OP has failed to load the package that provides next function.
myTheme<-rasterTheme(region=rainbow(15,s=1,v=1,start=0,end=0.7))     


  levelplot(RawData1~x*y,data=dat1,legend.shrink=0.5,xlab=list("Time",font=1,cex=1.5,col="brown"),colorkey=list(labels=list(cex=1,font=2,col="brown"),height=1,width=1.4),main=list('',side=1,line=0.5),ylab=list("Latitude",font=1,cex=1.5,col="brown"), panel=panel.levelplot.raster,interpolate=TRUE,par.settings=myTheme,at=my.at,scales=list(x=list(rot=0,cex=1,font=2,col="brown"),y=list(rot=0,cex=1,font=2,col="brown")))

这将绘制此

我的问题是如何用虚线或浅色标记纬度23S和23N之间的区域? 谢谢你的帮助

1 个答案:

答案 0 :(得分:2)

使用panel.rect。如果您更喜欢标准面板定义,请定义自定义面板:

library(lattice)
library(latticeExtra)

rX <- as.numeric(range(dat1$x))

levelplot(RawData1 ~ x*y, data = dat1,
          par.settings = custom.theme,
          panel = function(...){
          panel.levelplot.raster(...)
          panel.rect(rX[1], -23, rX[2], 23,
                 col = 'lightgray', border = 'lightgray',
                     alpha = 0.6)
      })

虽然您可以使用layer的{​​{1}}功能:

latticeExtra