Dear All,
Please consider the snippet at the end of the email.
My problem is rather simple: I can generate individual maps of a country
where each region is colored according to a scalar, but I am experiencing
problems when I try to combine e.g. 2 maps into a single figure using the
mfrow(2,1) parameter.
This does not give me any trouble when I use "plot", but I must be
misunderstanding something when I resort to "spplot" (one plot gets
overwritten and no panel is generated).
Any suggestion is really appreciated.
Cheers
Lorenzo
#########################################################################################
library(sp)
con <- load("ITA_adm1.RData")
unemployment <- c(6.2,11.2,9.5,11.2,11.2,2.9,
3.4,6.4,4.8,3.4,4.2,8.1,4.2,9.9,13.0,4.3,2.7,4.6,3.2,3.3)
gadm$unemployment <- as.factor(unemployment)
col = rev(heat.colors(length(levels(gadm$unemployment))))
par.set <- list(axis.line=list(col="transparent"),
clip=list(panel="off"),
par.main.text=list(col="white"),
axis.text=list(col="white"), fontsize=list(text=18))
png("unemployment2.png", width=630, height=630, bg="grey15")
print(spplot(gadm, "unemployment", col.regions=col, col="grey15",
main=list(label="Italia - Tassi di disoccupazione 2007"),
res=88, par.settings=par.set))
dev.off()
png("unemployment-panel.png", width=630, height=630, bg="grey15")
par(mfrow=c(2,1), mar = c(4.5,5, 1, 1) + 0.1)
print(spplot(gadm, "unemployment", col.regions=col, col="grey15",
main=list(label="Italia - Tassi di disoccupazione 2007"),
res=88, par.settings=par.set))
print(spplot( gadm, "unemployment", col.regions=col, col="grey15",
main=list(label="Italia - Figure 2"),
res=88, par.settings=par.set))
dev.off()
Panels of Geographical Maps
2 messages · Lorenzo Isella
It turns out that there is already a solution http://bit.ly/NmZg3S Cheers Lorenzo ------- Forwarded message ------- From: "Lorenzo Isella" <lorenzo.isella at gmail.com> To: "r-help at stat.math.ethz.ch" <r-help at stat.math.ethz.ch> Cc: Subject: Panels of Geographical Maps Date: Tue, 11 Sep 2012 22:58:43 +0200 Dear All, Please consider the snippet at the end of the email. My problem is rather simple: I can generate individual maps of a country where each region is colored according to a scalar, but I am experiencing problems when I try to combine e.g. 2 maps into a single figure using the mfrow(2,1) parameter. This does not give me any trouble when I use "plot", but I must be misunderstanding something when I resort to "spplot" (one plot gets overwritten and no panel is generated). Any suggestion is really appreciated. Cheers Lorenzo ######################################################################################### library(sp) con <- load("ITA_adm1.RData") unemployment <- c(6.2,11.2,9.5,11.2,11.2,2.9, 3.4,6.4,4.8,3.4,4.2,8.1,4.2,9.9,13.0,4.3,2.7,4.6,3.2,3.3) gadm$unemployment <- as.factor(unemployment) col = rev(heat.colors(length(levels(gadm$unemployment)))) par.set <- list(axis.line=list(col="transparent"), clip=list(panel="off"), par.main.text=list(col="white"), axis.text=list(col="white"), fontsize=list(text=18)) png("unemployment2.png", width=630, height=630, bg="grey15") print(spplot(gadm, "unemployment", col.regions=col, col="grey15", main=list(label="Italia - Tassi di disoccupazione 2007"), res=88, par.settings=par.set)) dev.off() png("unemployment-panel.png", width=630, height=630, bg="grey15") par(mfrow=c(2,1), mar = c(4.5,5, 1, 1) + 0.1) print(spplot(gadm, "unemployment", col.regions=col, col="grey15", main=list(label="Italia - Tassi di disoccupazione 2007"), res=88, par.settings=par.set)) print(spplot( gadm, "unemployment", col.regions=col, col="grey15", main=list(label="Italia - Figure 2"), res=88, par.settings=par.set)) dev.off()