2

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?

Tomas
  • 57,621
  • 49
  • 238
  • 373

1 Answers1

5

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!

Tomas
  • 57,621
  • 49
  • 238
  • 373
  • This bizarrely doesn't work for me. Does for the example but not my RasterLayer object – geotheory Jan 08 '14 at 15:17
  • 1
    @geotheory ha, interesting! It seems that you need to set both `bty="n"` and `box=FALSE`! Maybe you were just setting `box=FALSE`? Updated my answer. – Tomas Jan 08 '14 at 15:27
  • Bonus question - any idea how to suppress the axis lines and tick marks but not the labels? – geotheory Jan 08 '14 at 15:47
  • @geotheory I don't know but try to suppress the axes and use the axis command to customize them. If you fail post a new question. – Tomas Jan 08 '14 at 16:05