result_map %>%
ggplot(aes(long, lat, group = group, fill = pourcentage_macron)) +
geom_polygon() + coord_map() +
scale_fill_viridis_c(name = "Macron") +
labs(x = "", y = "", title = "") + map_theme
Using the highcharter
package.
mapdata <- get_data_from_map(download_map_data("countries/fr/fr-all-all"))
data_fake <- mapdata %>%
select(code = `hc-a2`) %>%
mutate(frequence = 0.5 * abs(rt(nrow(.), df = 10)))
glimpse(data_fake)
# Observations: 103
# Variables: 2
# $ code <chr> "MB", "VD", "AD", "VC", "HM", "MR", "NO", "HP", "IN", "VN",…
# $ frequence <dbl> 0.04681094, 0.15558589, 0.08643633, 0.28813232, 0.18458058,…
## Observations: 52
hcmap("countries/fr/fr-all-all", data = data_fake, value = "frequence",
joinBy = c("hc-a2", "code"), name = "Fake data",
dataLabels = list(enabled = TRUE, format = '{point.name}'),
borderColor = "#FAFAFA", borderWidth = 0.1,
tooltip = list(valueDecimals = 2, valuePrefix = "$", valueSuffix = " USD")) %>%
hc_mapNavigation(enabled = TRUE)