Skip to content

Instantly share code, notes, and snippets.

@rCarto
Last active April 4, 2016 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rCarto/60357f577711a9c7174d6df2ac554401 to your computer and use it in GitHub Desktop.
Save rCarto/60357f577711a9c7174d6df2ac554401 to your computer and use it in GitHub Desktop.
Map of Panama Papers reporters
# load library
library(cartography)
# load data
load(url("http://wukan.ums-riate.fr/panamapapers/panamapapers.RData"))
# get the figures dimensions
fd <- getFigDim(spdf = grat, width = 800,
res = 120, mar = c(0,0,1.2,0))
# save to a png file
png(filename = "Panama Papers.png", width = fd[1], height = fd[2],
res = 120, bg = "white")
# set margins
par(mar = c(0,0,1.2,0))
# plot the world countries
plot(grat, col = "#cdd2d4", border = NA, add=F)
plot(world, col = "#f5f5f3ff", border = "#a9b3b4ff", add = T)
plot(grat, col = NA, border = "#a9b3b4ff", add=T)
# plot the number of reporters/country
propSymbolsLayer(spdf = world, df = PP,
spdfid = "ISO3", dfid = "ID",
var = "n", inches = 0.15, symbols = "circle",
col = "#B3490E", border = "#f5f5f3ff", lwd = 0.5,
legend.title.txt = "Number of reporters",
legend.style = "c", legend.values.cex = 0.45,
legend.pos = "topleft")
# add a layout
layoutLayer(scale = NULL, frame = FALSE,
col = "#A33A00", coltitle = "white",
title = "Where are the 'Panama Papers' Reporters?",
sources = "Source: T. Giraud - 2016",
author = "ICIJ - 2016 - https://panamapapers.icij.org/about.html")
# add a label for countries with at least 10 reporters
labelLayer(spdf = world, df = PP[PP$n>=10,],
spdfid = "ISO3", dfid = "ID",
txt = "label", cex = 0.45, font = 2)
# add a text to the map
text(x = -15368058, y = -5000000,
font = 2, srt = 33, cex = 1, pos = 4,
labels = paste (sum(PP$n), " reporters\nfrom ",
nrow(PP), " countries\n", sep=""))
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment