[![require(raster)
require(dismo)
oc_go<-gmap(extent(c(10042219 ,19646634,-7110934,1881964)),type='terrain')
plot(oc_go)
... add another layer
legend("bottom", legend = c(" 1", " 2"," 3"," 4"," 5"," 6"," 7"," 8"), fill = colvec,
cex = 0.7, inset = 0.9,xpd=T,horiz = T)
The result is
I would like to put the legend on the bottom or outside of the plotting area.
Using par() like this
par(xpd = FALSE,mar=c(5.1, 4.1, 4.1, 4.5))
plot(oc_go)
par(xpd = TRUE)
legend(par()$usr[2] ,-1000000, legend = c(" 1", " 2"," 3"," 4"," 5"," 6"," 7"," 8"), fill = colvec,
cex = 0.7, inset = 0.9)
doesn't seem to work very well with the map downloaded with gmap(). I tried also overlying the plot area as described in answer 3 here Plot a legend outside of the plotting area in base graphics?