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). For each of these layout themes, there is also an extra wide variant, with more space for the legend. Tip: create a layout theme for your own map (see example below).tm_layout(title = NA, scale = 1, title.size = 1.3, bg.color = NULL,
draw.frame = TRUE, asp = NA, frame.lwd = 1, outer.margins = rep(0.02,
4), inner.margins = rep(0.02, 4), outer.bg.color = NULL,
legend.show = TRUE, legend.only = FALSE, legend.position = NULL,
legend.width = 0.3, legend.height = 0.9, legend.hist.height = 0.3,
legend.hist.width = legend.width, legend.title.size = 1.1,
legend.text.size = 0.7, legend.hist.size = 0.7,
legend.scientific = FALSE, legend.digits = NA, legend.frame = FALSE,
legend.bg.color = NA, legend.bg.alpha = 1, legend.hist.bg.color = NA,
legend.hist.bg.alpha = 1, title.snap.to.legend = FALSE,
title.position = c("left", "top"), title.bg.color = NA,
title.bg.alpha = 1, design.mode = FALSE)
tm_layout_World(title = NA, inner.margins = c(0, 0.05, 0.025, 0.01),
legend.position = c("left", "bottom"), scale = 0.8, ...)
tm_layout_World_wide(title = NA, inner.margins = c(0, 0.2, 0.025, 0.01),
legend.position = c("left", "bottom"), legend.width = 0.4, scale = 0.8,
...)
tm_layout_Europe(title = NA, title.position = c("left", "top"),
legend.position = c("left", "top"), inner.margins = c(0, 0.1, 0, 0), ...)
tm_layout_Europe_wide(title = NA, title.position = c("left", "top"),
legend.position = c("left", "top"), inner.margins = c(0, 0.25, 0, 0),
legend.width = 0.4, legend.hist.width = 0.4, ...)
tm_layout_NLD(title = NA, draw.frame = FALSE, inner.margins = c(0.02, 0.2,
0.06, 0.02), legend.position = c("left", "top"), legend.width = 0.4, ...)
tm_layout_NLD_wide(title = NA, draw.frame = FALSE, inner.margins = c(0.02,
0.3, 0.06, 0.02), legend.position = c("left", "top"), legend.width = 0.5,
legend.hist.width = 0.35, ...)legend.config) is used as a title.scale, lwd, or s"white". A recommended alternative for choropleths is light grey (e.g., "grey85").NA, it is determined by the bounding box (see argument bbox of tm_shape), the outer.margins, and the legend.height, the histogram is downscaled as well.legend.width.TRUE to match with the overall background color bg.color.legend.bg.color is used (normally 1).legend.hist.bg.color is used (normally 1).TRUE to match with the overall background color bg.color.title.bg.color is used (normally 1).TRUE, inner and outer margins, legend position, aspect ratio are explicitely shown. Also, feedback text in the console is given.tm_layoutvignette("tmap-nutshell")}data(World)
tm_shape(World) +
tm_fill("pop_est_dens", style="kmeans", title="Population density") +
tm_layout_World("World Population", bg.color="lightblue")
# A custom layout wrapper for Africa
tm_layout_Africa <- function(title=NA,
inner.margins = c(.02, .25, .02, .02),
draw.frame = FALSE,
title.position=c("left", "bottom"),
legend.position = c("left", "bottom"),
legend.width = 0.5,
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", fill.title="Population density") +
tm_layout_Africa("Africa")Run the code above in your browser using DataLab