You can make continuous maps with tuichartr
and tuimaps
function. It works with sf
objects, we’ll use package rnaturalearth
to retrieves shapes.
Mapping for require 3 aesthetics:
# Retrieve Italy polygons
italy <- ne_states("italy", returnclass = "sf")
# add a random numeric variable
italy$random <- sample(1:100, nrow(italy), TRUE)
# draw map
tuimap(width = 500, height = 500) %>%
add_map_data(italy, aes(code = adm1_code, label = name, value = random)) %>%
tui_chart(title = "Italy map")
#> Registered S3 method overwritten by 'geojsonlint':
#> method from
#> print.location dplyr
An other example, with some options:
africa <- ne_countries(continent = "africa", returnclass = "sf")
africa$random <- sample(1:100, nrow(africa), TRUE)
tuimap(width = 700, height = 900) %>%
add_map_data(africa, aes(code = sov_a3, label = name, value = random)) %>%
tui_chart(
title = "Africa map",
format = JS("function(value) {return value + '%'}")
) %>%
tui_theme(
series = list(
startColor = "#DEEBF7",
endColor = "#084594"
)
)