Search code examples
rraster

How to add a text to a levelplot?


library(raster)
library(rasterVis)
 r <- raster(nrows=10, ncols=10)
 r <- setValues(r, 1:ncell(r))
levelplot(r)

I want to put a word (a text) that is "Original map" under the xlab "Longitude"

Is this possible?


Solution

  • This is a manual solution, but you can use mtext to place text around margins with line and adj parameters to put it where you want (or text).

    plot.new()  # open new plot
     r <- raster(nrows=10, ncols=10)
     r <- setValues(r, 1:ncell(r))
    levelplot(r)
    
    mtext("Original map", 1, line=-3.4, adj=0.4)
    

    enter image description here