add_bubbles: Add bubbles

Description Usage Arguments Examples

View source: R/add.R

Description

Add bubbles to the map.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
add_bubbles(
  p,
  lon,
  lat,
  radius,
  color,
  name,
  ...,
  colors = c("#FFEDA0", "#FEB24C", "#F03B20")
)

Arguments

p

a datamaps object.

lon, lat

coordinates of bubbles.

radius

radius of bubbles.

color

color of bubbles.

name

name of bubbles.

...

any other variable to use in tooltip.

colors

color palette.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
coords <- data.frame(city = c("London", "New York", "Beijing", "Sydney"),
                     lon = c(-0.1167218, -73.98002, 116.3883, 151.18518),
                     lat = c(51.49999, 40.74998, 39.92889, -33.92001),
                     values = runif(4, 5, 17))

coords %>%
    datamaps() %>%
    add_bubbles(lon, lat, values * 2, values, city)

data <- data.frame(name = c("USA", "FRA", "CHN", "RUS", "COG", "DZA"),
    color = round(runif(6, 1, 10)))

data %>%
    datamaps(default = "lightgray") %>%
    add_choropleth(name, color) %>%
    add_data(coords) %>%
    add_bubbles(lon, lat, values * 2, values, city, colors = c("red", "blue"))

JohnCoene/datamaps documentation built on Aug. 30, 2020, 7:20 a.m.