Skip to contents

About the data

A spatial data object contained in tmap is called World. It is a data frame with a row for each country. The columns are the following data variables plus an additional geometry column which contains the geometries (see sf package):

names(World)
#>  [1] "iso_a3"       "name"         "sovereignt"   "continent"    "area"        
#>  [6] "pop_est"      "pop_est_dens" "economy"      "income_grp"   "gdp_cap_est" 
#> [11] "life_exp"     "well_being"   "footprint"    "HPI"          "inequality"  
#> [16] "gender"       "press"        "geometry"

We specify this object with tm_shape (see other vignette) and for convenience assign it to s:

s = tm_shape(World, crs = "+proj=eqearth")

Constant values

s + tm_polygons(fill = "#ffce00", # fill color
                col = "black",    # line color
                lwd = 0.5,        # line width
                lty = "dashed")   # line type

For advanced users: the default constant values are specified for combinations of visual variables and layer type. See tmap_options("value.const")

Visual variables

s + tm_polygons(fill = "press")   # data variable (column in World)

s + tm_polygons(fill = "grey90") +
  tm_bubbles(size = "pop_est",
           fill = "well_being",
           shape = "income_grp",
           size.scale = tm_scale(values.scale = 3))
#> [plot mode] fit legend/component: Some legend items or map compoments do not
#> fit well, and are therefore rescaled.
#>  Set the tmap option `component.autoscale = FALSE` to disable rescaling.