Question

I defined a layout to plot three different plots as:

layout(matrix(c(1,2,3,4),2,2,byrow = TRUE), TRUE)

After that I call the three plots that I want to produce:

image.plot(...)
plot(...)
plot(...)

I will also need to overlay a map (generated with getMap form the rworldmap package ) to the image.plot (in the fields package) with another call like:

newmap <- getMap(resolution = "high")
plot(newmap)  

But because of the layout structure R is interpreting this as the next plot to draw. Is there a way to overlay the map in the same position of image.plot plot and then continue with the other plots?

Thanks

Was it helpful?

Solution

I found a function getMap in the rworldmap package, is that the one that you are using?

If so, it looks like it uses the methods from the sp package to do the plotting, these methods have an add argument that when set to TRUE will add the map to the current plot rather than starting a new plot. So try something like:

image.plot(...)
newmap <- getMap(resolution="high")
plot(newmap, add=TRUE)

and see if that works for you.

And in the future, please specify which packages your are using and give details that will help people help you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top