Proportional symbol map with the Cartography package

The cartography package is a great alternative to make maps with R. This post explains how to build a bubble map using it, with explanation and reproducible code.

Bubble map section About Maps

The cartography package is a very good alternative to the other tools presented in the gallery for building maps.

It notably allows to:

  • display a legend with embedded circles
  • add data sources on the bottom of the chart
  • show north / south

# Library

# Upload data attached with the package.

# Now we have a geospatial object called nuts2.spdf containing the shape of european regions. We can plot it with the plot function.
# summary(nuts2.spdf)

# We also have a dataframe with information concerning every region.
# head(nuts2.df)
# Both object have a first column "id" that makes the link between them.

# Plot Europe
plot(nuts0.spdf, border = NA, col = NA, bg = "#A6CAE0")
plot(world.spdf, col = "#E3DEBF", border = NA, add = TRUE)
plot(nuts0.spdf, col = "#D1914D", border = "grey80",  add = TRUE)

# Add circles proportional to the total population
propSymbolsLayer(spdf = nuts0.spdf, df = nuts0.df,
    var = "pop2008", symbols = "circle", col = "#920000",
    legend.pos = "right", legend.title.txt = "Total\npopulation (2008)", = "c")

# Add titles, legend...
layoutLayer(title = "Countries Population in Europe",
    author = "cartography", sources = "Eurostat, 2008",
    scale = NULL, south = TRUE)

Related chart types

Hexbin map
Bubble map


This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message on Twitter, or send an email pasting with

Github Twitter