<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/updated-circular-plots-for-directional-bilateral-migration-data/"></div></div><div><a data-url="http://www.r-bloggers.com/updated-circular-plots-for-directional-bilateral-migration-data/" data-counturl="http://www.r-bloggers.com/updated-circular-plots-for-directional-bilateral-migration-data/" data-count="horizontal" data-text="Updated Circular Plots for Directional Bilateral Migration Data" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://gjabel.wordpress.com/2016/05/18/updated-circular-plots-for-directional-bilateral-migration-data/"> R – Guy Abel</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>I have had a few emails recently regarding plots from my new <a target="_blank" href="http://www.oeaw.ac.at/vid/download/WP2016_02.pdf">working paper</a> on global migration flows, which has received some media coverage <a target="_blank" href="http://www.spiegel.de/international/world/why-global-migration-statistics-do-not-add-up-a-1090736.html">here</a>, <a target="_blank" href="http://www.newscientist.com/article/mg23030680-700-the-truth-about-migration-how-it-will-reshape-our-world/">here</a> and <a target="_blank" href="http://www.bbc.co.uk/programmes/p03v1hm3/">here</a>. The plots were created using Zuguang Gu’s excellent <a target="_blank" href="https://cran.r-project.org/web/packages/circlize/index.html">circlize</a> package and are modified version of those discussed in an earlier <a target="_blank" href="https://gjabel.wordpress.com/2014/03/28/circular-migration-flow-plots-in-r/">blog post</a>. In particular, I have made four changes:</p>
<ol>
<li>I have added arrow heads to better indicate the direction of flows, following the example in <a target="_blank" href="http://www.scientificamerican.com/article/immigrants-move-up-the-wealth-ladder-in-steps/">Scientific American</a>.</li>
<li>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.</li>
<li>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.</li>
<li>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.</li>
</ol>
<p>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.</p>
<p>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;</p>
<pre>
# install.packages(&quot;migest&quot;)
# install.packages(&quot;circlize&quot;)
library(&quot;migest&quot;)
demo(cfplot_reg2, package = &quot;migest&quot;, ask = FALSE)
</pre>
<p>which will give the following output:</p>
<p><img alt="Estimated Global Migration Flows 2010-15" class="wp-image-1557" src="https://gjabel.files.wordpress.com/2016/05/cfplot_reg2.png?w=840"></p>
<p>The code in the demo script uses the <code>chordDiagram</code> 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 <code>install.packages</code> lines in the code above).</p>
<p>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 <a target="_blank" href="http://github.com/gjabel/migest/blob/master/demo/cfplot_reg2.R">here</a>. I provide some comments (in the script, below the function) to explain each of the argument values.</p>
<p>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:</p>
<pre>
dev.copy2pdf(file = &quot;cfplot_reg2.pdf&quot;, height=10, width=10)
file.show(&quot;cfplot_reg2.pdf&quot;)
</pre>
<p> </p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gjabel.wordpress.com/1548/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/gjabel.wordpress.com/1548/" border="0"></a> <img height="1" alt="" width="1" src="https://pixel.wp.com/b.gif?host=gjabel.wordpress.com&blog=13658317&%23038;post=1548&%23038;subd=gjabel&%23038;ref=&%23038;feed=1" border="0"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/updated-circular-plots-for-directional-bilateral-migration-data/"></div></div><div><a data-url="http://www.r-bloggers.com/updated-circular-plots-for-directional-bilateral-migration-data/" data-counturl="http://www.r-bloggers.com/updated-circular-plots-for-directional-bilateral-migration-data/" data-count="vertical" data-text="Updated Circular Plots for Directional Bilateral Migration Data" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://gjabel.wordpress.com/2016/05/18/updated-circular-plots-for-directional-bilateral-migration-data/"> R – Guy Abel</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/92QwIxX_hFw"></a></div>