tm_layout
can be seen as a general layout theme. The functions tm_layout_World
, tm_layout_Europe
, and tm_layout_NLD
are layout themes specified for the world, Europe, and Netherlands maps (which are contained in this package). Tip: create a layout theme for your own map (see example below).tm_layout(title = NA, scale = 1, title.cex = 1.5, bg.color = NULL,
draw.frame = TRUE, title.position = NULL, title.bg.color = NA,
asp = NA, frame.lwd = 1, outer.margins = rep(0.02, 4),
inner.margins = rep(0.02, 4), outer.bg.color = "white",
legend.show = TRUE, legend.hist.show = FALSE, legend.only = FALSE,
legend.titles = c(fill = NA, bubble.size = NA, bubble.col = NA, line.col =
NA, line.lwd = NA), legend.position = NULL, legend.is.portrait = c(fill =
TRUE, bubble.size = FALSE, bubble.col = TRUE, line.col = TRUE, line.lwd =
FALSE), legend.width = 0.3, legend.height = 0.9,
legend.hist.height = 0.3, legend.config = c("fill_hist", "fill",
"bubble.size", "bubble.col", "line.col", "line.lwd"), legend.title.cex = 1,
legend.text.cex = 0.7, legend.hist.cex = 0.7, legend.scientific = FALSE,
legend.digits = NA, legend.bg.color = NA)
tm_layout_World(title = NA, scale = 0.85, title.bg.color = TRUE,
inner.margins = c(0, 0.02, 0.02, 0.02), legend.position = c("left",
"bottom"), legend.width = 0.25, legend.height = 0.5,
legend.bg.color = TRUE, ...)
tm_layout_Europe(title = NA, title.position = c("left", "top"),
legend.position = c("left", "top"), inner.margins = c(0, 0.15, 0, 0), ...)
tm_layout_NLD(title = NA, draw.frame = FALSE, inner.margins = c(0.05, 0.3,
0.1, 0.05), legend.position = c("left", "top"), legend.width = 0.35, ...)
legend.config
) is used as a title.scale
, lwd
, or c
grey85
) for choropleths and white for other maps.TRUE
to match with the overall background color bg.color
.NA
, it is determined by the bounding box (see argument bbox
of tm_shape
) and the argument frame.margins
. legend.config
to configure which legend elements are shown."fill"
, "bubble.size"
, "bubble.col"<
TRUE
) or landscape (FALSE
). The vector should be named with the corresponding elements, which are "fill"
, "bubble.size
legend.height
, the histogram is downscaled as well."fill"
, "fill_hist"
, "bubble.size"
, "bubble.col"
, "line.col"
, and "
TRUE
to match with the overall background color bg.color
.tm_layout
vignette("tmap-nutshell")
}data(World)
tm_shape(World) + tm_fill("pop_est_dens", style="kmeans") +
tm_layout_World("World Population")
# A custom layout wrapper for Africa
tm_layout_Africa <- function(title=NA,
inner.margins = c(.02, .4, .02, .02),
draw.frame = FALSE,
title.position=c("left", "bottom"),
legend.position = c("left", "bottom"),
bg.color = "lightskyblue2", ...) {
args <- c(as.list(environment()), list(...))
do.call("tm_layout", args)
}
Africa <- World[World$continent=="Africa", ]
qtm(Africa, fill="pop_est_dens", fill.style="kmeans") +
tm_layout_Africa("Population of Africa")
Run the code above in your browser using DataLab