I would like to plot a file that can be downloaded from here:
the code:
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")))
this will plot this
My question is how to mark the areas between latitudes 23S and 23N with dashed lines or light shade? Thanks for your help
Use panel.rect
. If you prefer the standard panel definition define a custom panel:
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)
})
Although you may use the layer
function of latticeExtra
:
p <- levelplot(RawData1 ~ x*y, data = dat1,
par.settings = custom.theme,
panel = panel.levelplot.raster)
p + layer(panel.rect(rX[1], -23, rX[2], 23,
col = 'lightgray', border = 'lightgray',
alpha = 0.6))