Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How can I add a subplot within a plot using levelplot in R?

$
0
0

I would like to add a subplot in my main levelplot, something similar to this image. I want lat/lon axis for both my maps but I have not managed to find a way to do this with the levelplot. Also, I've seen this question but has no answer. I am quite confused about the subplot and the new par(), so I would really like some help.

library("raster")
library ("rasterVis")
library("viridis")

r <- raster(system.file("external/test.grd", package="raster"))#subplot
r2<-r/2 #main plot
ckey <- list(labels=list(cex=1.5), height=1,space='top')
levelplot(r2,colorkey=ckey,margin=FALSE,xlab="", ylab="",col.regions=viridis,at=seq(100,500, len=20),
          scales=list(x=list(cex=1.5),y=list(cex=1.5))) #from this point, I do not know how to add a subplot

Viewing all articles
Browse latest Browse all 201839

Trending Articles