首页 > 解决方案 > 如何在 levelplot 中调整 NA 值的颜色?

问题描述

我有一个光栅堆栈,我想使用 R 使用 rastervis 包中的 levelplot 绘制它。NA 值显示为灰色,由 panel.background=list(col='gray') 指定。但是,我想将 NA 值保持在德国白色边界之外。关于如何实现这一目标的任何建议?

这是我的代码:

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

这就是这个数字目前的样子: 在此处输入图像描述

非常感谢你的帮助!

标签: rcolorsnalevelplot

解决方案


推荐阅读