Learn R Programming

datamaps (version 0.0.3)

add_legend: Add legend

Description

Add a legend to the map.

Usage

add_legend(p)

Arguments

p

a datamaps object

Examples

Run this code
# NOT RUN {
data <- data.frame(name = c("USA", "FRA", "CHN", "RUS", "COG", "DZA"),
    values = c("N. America", "EU", "Asia", "EU", "Africa", "Africa"))

data %>%
    datamaps() %>%
    add_choropleth(name, values, colors = c("skyblue", "yellow", "orangered")) %>%
    add_legend()

# }

Run the code above in your browser using DataLab