Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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