It is spring, and the flowers bloom. One tree in particular symbolises this: the Japanese cherry (sakura) tree. Every year, millions of Japanese enjoy hanami, jointly watching the cherry blossoms, philosophising about the the transient nature of beauty, and the inevitability of death.
There are regular “sakura forecasts” on TV, and elsewhere. The Japanese National Tourist Office has its own map and details available on their website as well.
The data and graph section of The Economist recently published a beautiful chart showing 1200 years of data on the cherry blossom – as well as one of their customary great puns: “the elephant in the bloom”. I wondered if I could replicate the graph in R.
I remembered an emoji font I had stumbled across, and that there is a sakura (cherry blossom) emoji. I also felt a bit competitive – with a Japanese on this blog’s author roll, and another author being a certified expert on emojis, I felt that I needed show off that I, too, can poach in their areas of expertise!
The Economist’s article mentions a professor Yasuyuki Aono, who wrote several papers using data on Japanese cherry blossom dates. A quick googleing brought up his homepage. He also linked to a page detailing the cherry blossom data. Fantastic! A pretty straightforward data grab, it is then.
1 |
|
We download the data if not available on disk, do some cleaning of column names, and generate a proper date column of the full flowering date, since this is the data with the most observations.
It’s a fascinating dataset: 1200 years of human records on a yearly event! It’s not often that one can work with these kinds of data. For this, I would like to thank professor Aono. Generating such a historical dataset is a tremendous amount of work (he probably had to find and read through hundreds of historical records), and providing the data on his homepage is not something I see often in academia.
The original emoji graphing system I had in mind, emoGG
, worked, but I could not change the size of the individual emojis. It turns out, emoGG
is deprecated, and I should look at emojifont
instead.
emojifont
uses geom_text()
to draw the emojis onto a ggplot()
graph. After a quick install of the font I was ready to go. Two things one needs to keep in mind when working with emojifont
: you will need to load the font to start with, and if you’re using RStudio, you will need to initialise a new graphics environment. The standard RStudio environment is not able to preview/show the fonts. Both can be accomplished with these commands:
1 |
|
One other thing that was problematic: emojifont
uses a font to populate the graph by ggplot2::aes(label = "labelname")
to specify the emoji. It needs the label pulled from the original dataset, and not generated within the aes()
.
1 |
|
I created the common.date
variable to scale the y-axis of the graph to a month-day format.
1 |
|
To copy the Economist’s graph as closely as possible, I manually set the y-axis breaks. The x-axis breaks are more interesting, because the original graphs has major ticks every 200 years, labelled, and minor ticks every 100 years in between, which are not labelled. This is unfortunately not possible in ggplot
, currently, so I had to resort to a workaround.
I create the sequence of years, with ticks every 100 years (so 800, 900, 1000, ...
). I then “overwrite” every even element (900, 1100, 1300, ...
) of the vector, resulting in a “blank” label for those years. The axis label would thus look like this: 800, "", 1000, "", 1200, ...
.
1 |
|
All that remains then are some theme()
hacking to get the graph pretty.
Behold, 1200 years of cherry blossom history!
I’m not super happy with the graph colours, it seems too “light”, and pastel. Not really very readable. The Economist’s version is in purple; much more readable and much prettier to look at. I did want to use the sakura pink tones, though, and thus the graph colour scheme seems as fragile and transient as the actual sakura blossoms.
The code is available on github, as always.
Aono uses the data to predict March temperatures, and in various papers he manages to do this to an astonishing degree of accuracy: 0.1°C.
It’s very disheartening to see the blossom dates dramatically moving earlier into the year in the last 50 years. Global warming is to blame, and it always saddens me that people chose to ignore these facts… As a cold-loving northern German, I will need to find a retirement location in northern Norway, if things continue the way they do!