图例选项 - R 光栅图例

3

我该如何移除栅格图例周围的黑色框?更一般地,我在哪里可以找到有关R栅格图例选项的文档?

   require(raster)
        data(volcano)
        r <- raster(volcano)
        plot(r, col=topo.colors(100), legend=FALSE, axes=FALSE)
        r.range <- c(minValue(r), maxValue(r))
        plot(r, legend.only=TRUE, col=topo.colors(100),
             legend.width = 2,
             axis.args=list(at=seq(r.range[1], r.range[2], 25),
                            labels=seq(r.range[1], r.range[2], 25), 
                            cex.axis=0.6),
             legend.args=list(text='Elevation (m)', side=4, font=2, line=2.5, cex=0.8))
1个回答

3
您可以在绘制图例之前使用par(bty='n')
par(bty= "n") # remove the box
plot(r, legend.only=TRUE, col=topo.colors(100),
     legend.width = 2,
     axis.args=list(at=seq(r.range[1], r.range[2], 25),
                    labels=seq(r.range[1], r.range[2], 25), 
                    cex.axis=0.6),
     legend.args=list(text='Elevation (m)', side=4, font=2, line=2.5, cex=0.8))
par(bty= "o") # set the box

enter image description here


谢谢!你有关于通常如何找到这类修复方法的建议吗?我在寻找作图光栅图例的文档中进行了搜索,很明显这个修复是独立于那个的。 - undefined
1
通常,特定的plot()文档只描述它们自己的部分,所以对于通用的绘图选项(不特定于光栅),您需要查看通用的plot()文档(?plot然后选择基本R)。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接