[R-sig-Geo] Putting Multiple spplots in the same page
Barry Rowlingson
b.rowlingson at lancaster.ac.uk
Tue Jul 17 18:55:29 CEST 2012
On Tue, Jul 17, 2012 at 5:19 PM, Roosbeh Nowrouzian
<roosbeh.nowrouzian at gmail.com> wrote:
> Dear List members:
>
> While par(mfrow=c(i,j)) works for plot function, I met a problem with
> spplot function. Even after defining e.g. par(mfrow=c(2,2)) The spplot
> draws each figure separately.Here is an example:
>
> par(mfrow=c(2,2))
>
> data(meuse)
> coordinates(meuse) <- ~x+y
>
> spplot ( meuse, "zinc")
> spplot(meuse,"copper")
> spplot(meuse,"lead")
> spplot(meuse,"cadmium")
>
> Does any one knows how to put multiple spplot in the same page?
>
Either ditch spplot and realise that for single maps all that
spplot(foo,"bar") is doing is essentially plot(foo,col=f(foo$bar)).
Just write a function f to map values to colours in a palette and do
that, with par(mfrow=c(2,2)). Also, spplots default palette is awful
for points - you'll get white points on a white background, so don't
use that.
If you dont want to customise your maps with base graphics you need to
dive into grid graphics, get the gridExtra package and then:
> require(gridExtra)
> grid.arrange(spplot(meuse,"zinc"),spplot(meuse,"cadmium"),spplot(meuse,"lead"),spplot(meuse,"copper"),ncol=2)
Its a whole new world. Anyway, you'll probably want to do this with
ggplot2 next...
Barry
More information about the R-sig-Geo
mailing list