Search code examples
rraster

R - plot raster without box


I have a problem getting rid of the box when plotting raster with colour scale:

require(raster)
data(volcano)
raster <- raster(volcano)

colfunc <- colorRampPalette(c("blue", "red"))
plot(raster, col = colfunc(40), breaks = seq(minValue(raster), maxValue(raster), length.out = 40), bty = "n", xaxt = "n", yaxt = "n")

the bty option simply doesn't work. Am I missing something here?


Solution

  • Got it:

    plot(raster, ..., bty="n", box=FALSE)
    

    It is interesting that both bty="n" and box=FALSE must be set! If you try only one of these, the box will be printed!