This post describes how to make a smooth transition GIF between a chloropleth map and a cartogram. It starts by doing a basic map of Africa and then distorts country size using the cartogram library. Ggplot2 is then used to make a nice chloropleth version. Finally the tweenr and the gganimate libraries build a smooth transition between both maps. At the end of this post, you should obtain a .gif file that looks like this: Continue reading
This post explains how to draw connection lines between several localizations on a map, using R. The method proposed here relies on the use of the gcIntermediate function from the geosphere package. Instead of making straight lines, it offers to draw the shortest routes, using great circles. A special care is given for situations where cities are very far from each other and where the shortest connection thus passes behind the map. Continue reading
Plotly is an R library allowing to make amazing interactive charts in a minute. This blog post shows how to get the best from ggplotly, the function of plotly allowing you to turn any ggplot2 chart interactive. A special care is given on features that are not present in ggplot2 (like hovering), and features that are not well translated by ggplotly (like legend position). Continue reading
I recently worked on a dataviz project involving Shiny and the Leaflet library. In this post I give 4 handy tricks we used to improve the app: 1/ how to use leaflet native widgets 2/ how to trigger an action when user clicks on map 3/ how to add a research bar on your map 4/ how to propose a “geolocalize me” button. For each trick, a reproducible code snippet is provided, so you just have to copy and paste it to reproduce the image. Continue reading
A word cloud (or tag cloud) is a visual representation of text data. Tags are usually single words, and the importance of each tag is shown with font size or color. This mode of representation is useful for quickly perceiving the most prominent terms in a list and determine their relative prominences. In R, two libraries will allow you to create wordclouds: Wordcloud and Wordcloud2. In this post I will introduce the main features of the awesome Wordcloud2 library developed by Chiffon Lang.
Welcome to the R graph gallery! One year ago, I realised that I was tired of learning how to code R charts again and again so I decided to create a reproducible code for each of them. I ultimately designed a new R graph gallery: a website that currently provides more than 200 R graphics and explains how to generate them.
The R graph gallery is almost 1 year old. I am starting a blogpage which will concern dataviz with R of course!