Learn R Programming

tmap (version 1.2)

save_tmap: Save tmap

Description

Save tmap to a file, such as png, jpg, or pdf.

Usage

save_tmap(tm, filename = shp_name(tm), width = par("din")[1],
  height = par("din")[2], units = c("in", "cm", "mm"), dpi = 300,
  outer.margins = 0, asp = 0, scale = NA, ...)

Arguments

tm
tmap object
filename
filename including extension, and optionally the path. The extensions pdf, eps, svg, wmf (Windows only), png, jpg, bmp, or tiff are supported. Use itmap to create an interactive svg.
width
width. Defaults to the width of current plotting window. Units are set with the argument units.
height
height. Defaults to the height of current plotting window. Units are set with the argument units.
units
units for width and height when either one is explicitly specified (in, cm, or mm)
dpi
dots per inch. Only applicable for raster graphics.
outer.margins
overrides the outer.margins argument of tm_layout (unless set to NA)
asp
overrides the asp argument of tm_layout (unless set to NA)
scale
overrides the scale argument of tm_layout (unless set to NA)
...
arguments passed on to device functions

Examples

Run this code
data(NLD_muni, NLD_prov)
(tm_shape(NLD_muni) +
	 tm_fill(col="population", convert2density=TRUE, 
	   style="kmeans", title="Population (per km2)", legend.hist=FALSE) +
	 tm_borders("black", alpha=.5) + 
tm_shape(NLD_prov) +
	 tm_borders("grey25", lwd=2) +
tm_format_NLD(inner.margins = c(.02, .15, .06, .15)) + 
tm_scale_bar(position = c("left", "bottom")) +
tm_compass(position=c("right", "bottom")) + 
tm_style_classic()) %>% save_tmap()

Run the code above in your browser using DataLab