{"id":58,"date":"2017-05-29T14:54:47","date_gmt":"2017-05-29T12:54:47","guid":{"rendered":"https:\/\/www.benscoat.eu\/?p=58"},"modified":"2020-11-27T10:59:55","modified_gmt":"2020-11-27T09:59:55","slug":"ggdiag","status":"publish","type":"post","link":"https:\/\/www.benscoat.eu\/index.php\/2017\/05\/29\/ggdiag\/","title":{"rendered":"ggdiag"},"content":{"rendered":"\n<p>Last week was a short one. Thursday was off, and in such circumstances, people here usually also take the Friday off, and enjoy a looooong week-end. More explanations about this phenomenon in this video: https:\/\/www.youtube.com\/embed\/0-6sM0vo9Tk<\/p>\n\n\n\n<p>I took this opportunity to work on a rather big project I&#8217;m truly dreaming of since years: plotting palynological diagrams with R! Since my Master studies, I&#8217;m using Tilia, which I became good at. I can produce complete, elegant diagrams, from scratch, in only a few hours. https:\/\/giphy.com\/embed\/CDJo4EgHwbaPS<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Yes, Tilia is great, but it takes time to get a nice diagram. And since this is a task we (palaeo-ecologists) do several times, regularly, to control the progress along the acquisition of data, it gets time-consuming.<\/p>\n\n\n\n<p>My current workflow starts with PolyCounter, and ends in Tilia. Everything in the middle is done with R. I import data files from PolyCounter to R, and do all the processing and preparation (i.e., format data in a Tilia-friendly shape) there. Thus, what about plotting diagram directly with R?<\/p>\n\n\n\n<p>A few alternative exist, the most known is probably the <code>strat.plot()<\/code> function from the package <code>rioja<\/code>. I tried it. I even tried to change some of its behaviour to get something closer to what Tilia can produce. But it was not enough, and I started to think about creating my own plotting solution. Of course, I would use <code>ggplot2<\/code>, because I love its beautiful* and meaningful syntax. I considered using a faceting approach, which is so convenient, until I came to the problem about setting individual scale limits for each facet. I read an article (can&#8217;t find it anymore, though) that stroke me: the data I&#8217;m trying to plot simply don&#8217;t have a common scale! So I moved to a new approach involving <code>ggarrange()<\/code> from the package <code>egg<\/code> and everything became simpler! In combination with the <code>tidyverse<\/code> functions, the data transformation was very handy.<\/p>\n\n\n\n<p>My plotting script is almost achieved, it already imports all the data, performs percentage, concentration and influx calculations in a second, and plots a nice diagram with desired colour, truncating high values, and with exaggeration curves! There are still a few things on my to-do list to make just <em>so pretty<\/em>, but it should come soon. Once it&#8217;s done, I&#8217;ll show you a demo \ud83d\ude09<\/p>\n\n\n\n<p>* Because, yes, code is also a kind of art.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last week was a short one. Thursday was off, and in such circumstances, people here usually also take the Friday off, and enjoy a looooong week-end. More explanations about this phenomenon in this video: https:\/\/www.youtube.com\/embed\/0-6sM0vo9Tk I took this opportunity to work on a rather big project I&#8217;m truly dreaming of since years: plotting palynological diagramsContinue reading &rarr;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2,5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/58"}],"collection":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/comments?post=58"}],"version-history":[{"count":1,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/58\/revisions"}],"predecessor-version":[{"id":59,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/58\/revisions\/59"}],"wp:attachment":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/media?parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/categories?post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/tags?post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}