albren
albren

Reputation: 109

How to adjust colour of NA values in levelplot?

I have a raster stack, which I would like to plot with levelplot from the rastervis package using R. The NA values are shown in grey as specified by panel.background=list(col='gray'). However, I would like to maintain the NA values outside the border of Germany white. Any suggestions on how to achieve this?

This is my code:

levelplot(stack_hist,  main="", 
      xlab=list("Longitude", cex=1), ylab=list("Latitude", cex=1),layout=c(2,2), 
      names.attr=c("A", "B" ,"C", "D"), par.strip.text= list(cex=1, lines=1), 
      colorkey=list(at=as.numeric(factor( c( seq(10, 180, by=10)))), 
                    labels=as.character( c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18")), col=c(color)),
      par.settings=list(strip.border=list(col='transparent'),strip.background=list(col='transparent'),axis.line=list(col='transparent'), panel.background=list(col='gray') ),
      scales=list(draw=F, x=list(cex=1), y=list(cex=1)), col.regions=color, at=my.at)+
      layer(sp.polygons(Ger_Bundesland, col = 'grey90')) +
      layer(sp.polygons(Ger_Land, col = 'grey95')) ## add polygon layer

And this is how the figure looks like currently: enter image description here

Thanks a lot for your help!

Upvotes: 1

Views: 215

Answers (0)

Related Questions