Learn R Programming

tmap (version 1.2)

itmap: Interactive thematic map

Description

Convert the tmap output to an interactive SVG, that can be plot in RStudio. In development.

Usage

itmap(tm, file = NULL, width = NULL, height = NULL)

Arguments

tm
tmap object. A tmap object is created with qtm or by stacking tmap-elements.
file
file name. If specified, the SVG image is saved to this file.
width
width
height
height

Examples

Run this code
data(World, metro)
metro$growth <- (metro$pop2020 - metro$pop2010) / (metro$pop2010 * 10) * 100

require(dplyr)

(tm_shape(World) +
	tm_polygons("income_grp", palette="-Blues", contrast=.7, id="name", title="Income group") +
	tm_shape(metro) +
	tm_bubbles("pop2010", col = "growth", 
			   border.col = "black", border.alpha = .5, 
			   style="fixed", breaks=c(-Inf, seq(0, 6, by=2), Inf),
			   palette="-RdYlBu", contrast=1, 
			   title.size="Metro population", 
			   title.col="Growth rate (%)", id="name") + 
	tm_layout(legend.bg.color = "grey90", legend.bg.alpha=.5, legend.frame=TRUE, asp=0)) %>% 
itmap()

Run the code above in your browser using DataLab