I am discontinuing this blog. Access to wordpress.com is blocked now and again in China – this has made it is difficult to update over the past couple of years and prohibits anyone in China viewing the site.
A couple of months ago, a paper I worked on with co-authors from the Wittgenstein Centre was published in the Proceedings for the National Academy of Science of the United States of America. The significance blurb and abstract are below.
Abel, G.J., Bakarat, B., K.C., S. and Lutz, W. (2016). Meeting the Sustainable Development Goals leads to lower world population growth. Proceedings of the National Academy of Sciences. 113 (50) 14294–14299
Between some of the games I had a go at replicating a plot from liberation.fr on the connections between Euro 2016 players and the country of birth using the
circlize package in R. As with the previous post, the colours are based on the home shirt of each team and data scraped from Wikipedia. The values in the parenthesis represent the total number of players born in the respective country, which dictates their ordering around the circle. It is interesting to see just how many players represent countries that they were not born in. Only Romania has a 23 man squad completely full of players born in the country and no other Romanian born players representing other nations.
This weekend I was having fun in France watching some Euro 2016 matches, visiting friends and avoiding Russian hooligans. Before my flight over I scraped some tables on the tournaments Wikipedia page with my newly acquired
rvest skills, with the idea to build up a bilateral database of Euro 2016 squads and their players clubs.
On the flight I managed to come up with some maps showing these connections. First off I used
ggplot2 to plot lines connecting the location of every players club teams to their national squads base in France. The path of the lines were calculated using the
gcIntermediate function in the
geosphere package. The lines colour is based on the national teams jersey, which I obtained via R using the amazing
extract_colours function in the
rPlotter package. Continue reading “Euro 2016 Squads”
I have had a few emails recently regarding plots from my new working paper on global migration flows, which has received some media coverage here, here and here. The plots were created using Zuguang Gu’s excellent circlize package and are a modified version of those discussed in an earlier blog post. In particular, I have made four changes:
- I have added arrow heads to better indicate the direction of flows, following the example in Scientific American.
- I have reorganized the sectors on the outside of the circle so that in each the outflows are plotted first (largest to smallest) followed by the inflows (again, in size order). I prefer this new layout (previously the inflows were plotted first) as it allows the time sequencing of migration events (a migrant has to leave before they can arrive) to match up with the natural tendency for most to read from left to right.
- I have cut out the white spaces that detached the chords from the outer sector. To my eye, this alteration helps indicate the direction of the flow and gives a cleaner look.
- I have kept the smallest flows in the plot, but plotted their chords last, so that the focus is maintained on the largest flows. Previously smaller flows were dropped according to an arbitrary cut off, which meant that the sector pieces on the outside of the circle no longer represented the total of the inflows and outflows.
Combined, these four modifications have helped me when presenting the results at recent conferences, reducing the time I need to spend explaining the plots and avoiding some of the confusion that occasionally occurred with the direction of the migration flows.
If you would like to replicate one of these plot, you can do so using estimates of the minimum migrant transition flows for the 2010-15 period and the demo R script in my migest package;
# install.packages("migest") # install.packages("circlize") library("migest") demo(cfplot_reg2, package = "migest", ask = FALSE)
which will give the following output:
The code in the demo script uses the
chordDiagram function, based on a recent update to the circlize package (0.3.7). Most likely you will need to either update or install the package (uncomment the
install.packages lines in the code above).
If you want to view the R script in detail to see which arguments I used, then take a look at the demo file on GitHub here. I provide some comments (in the script, below the function) to explain each of the argument values.
Save and view a PDF version of the plot (which looks much better than what comes up in my non-square RStudio plot pane) using:
dev.copy2pdf(file ="cfplot_reg2.pdf", height=10, width=10) file.show("cfplot_reg2.pdf")