I'm trying to get rid of some white space produced by levelplot in the rasterVis package. I'm using the dismo package to get a Google map, then using levelplot to plot it. However, there is a thin strip of white around the map. How do I remove that white space?
library(dismo)
library(rasterVis)
g_map = gmap(extent(c(-79,-58,36,50)),type="satellite",zoom=7,lonlat=TRUE,scale=1)
g_map_lv = levelplot(g_map,maxpixel=ncell(g_map),col.regions=g_map@legend@colortable,at=0:255,panel=panel.levelplot.raster,interpolate=TRUE,colorkey=FALSE,margin=FALSE,scales="sliced")
The outer rows and columns of the
g_map
object areNA
. For example:You can remove them with
trim
before plotting: