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:

I took this opportunity to work on a rather big project I'm truly dreaming of since years: plotting palynological diagrams with R! Since my Master studies, I'm using Tilia, which I became good at. I can produce complete, elegant diagrams, from scratch, in only a few hours.

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.

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?

A few alternative exist, the most known is probably the strat.plot() function from the package rioja. 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 ggplot2, 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't find it anymore, though) that stroke me: the data I'm trying to plot simply don't have a common scale! So I moved to a new approach involving ggarrange() from the package egg and everything became simpler! In combination with the tidyverse functions, the data transformation was very handy.

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 so pretty, but it should come soon. Once it's done, I'll show you a demo ;)

* Because, yes, code is also a kind of art.

This article is my 5th oldest. It is 386 words long, and it’s got 0 comments for now.