2016-06-09 87 views
0

如何去除光柵圖例周圍的黑盒?更一般地說,我在哪裏可以找到R柵格圖例選項的文檔?圖例選項 - 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

可以ploting傳說之前使用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

+0

謝謝!您是否有任何建議來尋找更一般的修補程序?我搜索了劇情光柵傳說的文檔,顯然這個修復與此不同。 – ZAC

+1

通常,特定的'plot()'文檔只描述它們的特定部分,因此對於繪製通用選項(不是專用於柵格),必須查看通用'plot()'文檔('plot'),然後選擇base R ) – HubertL