Dear R-SIG-GEO listers,

I'm having difficulties to solve what is probably an easy problem.

I'm preparing some maps using the function gmap from the package 'dismo'. I
am able to produce individual maps of the kind I want but now I would like
to produce a figure displaying several maps at the same time. What I want
is very much like using the function par(mfrow=c()) or par(fig=c()) to
divide the graphic device but I haven't been able to do it. I have tried
the functions par(mfrow()), par(fig()), layout, and split.screen, but none
seems to work with plot(gmap).

Below is a self-contained code to explain better what I'm trying to do:

# =====================

# installing and loading the required library:

install.packages("dismo")

library(dismo)


# first I'm going to plot a simple scatterplot rather than the map.

# generating some random numbers to plot:

x <- runif(10, 1, 10)

y <- runif(10, 1, 10)


# single plot:

plot(x,y)


# to plot four graphs in a single figure:

par(mfrow=c(2,2))

plot(x,y)

plot(x,y)

plot(x,y)

plot(x,y)


# to plot multiple graphs but customizing their sizes:

par(fig=c(0,0.5,0.5,1))

plot(x,y)

par(fig=c(0.5,1,0.5,1), new=T)

plot(x,y)

par(fig=c(0,1,0,0.5), new=T)

plot(x,y)


# Now I try the same with a gmap object:

# Plotting a map with dismo


g <- gmap("Lombock")

plot(g) # this produces a nice plot of the island of Lombock, in Indonesia


# I try to use par(mfrow()) to split the graphic device:

par(mfrow=c(2,2))

plot(g)

plot(g)

plot(g)

plot(g)

# it doesn't work

# I try to use par(mfrow()) to split the graphic device:

par(mfrow=c(2,2))

par(fig=c(0,0.5,0.5,1))

plot(g)

par(fig=c(0.5,1,0.5,1), new=T)

plot(g)

par(fig=c(0,1,0,0.5), new=T)

plot(g)

# again, it doesn't work


# attempts to use 'layout' and 'split.screen' also failed...
# =====================

Any idea of how can I do to map several maps at the same time?

Thank you very much and best regards,

Ahimsa

-- 
Ahimsa Campos-Arceiz
Associate Professor
School of Geography
The University of Nottingham Malaysia Campus
www.meme-elephants.org
http://www.facebook.com/MEME.project

*Je n'ai fait celle-ci plus longue que parce que je n'ai pas eu le loisir
de la faire plus courte.
Blaise Pascal, 1656*

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to