The R package ggbump creates elegant bump charts in ggplot. Bump
charts are good to use to plot ranking over time, or other examples when
the path between two nodes have no statistical significance. Also
includes functions to create custom smooth lines called sigmoid curves.
Installation
You can install ggbump from CRAN with:
install.packages("ggbump")
Or the latest development version from
github with:
To create a ranking column we use rank from base R. We specify
ties.method = "random" to make sure that each country have different
rankings if they have the same value.
ggbump
The R package
ggbumpcreates elegant bump charts in ggplot. Bump charts are good to use to plot ranking over time, or other examples when the path between two nodes have no statistical significance. Also includes functions to create custom smooth lines called sigmoid curves.Installation
You can install ggbump from CRAN with:
Or the latest development version from github with:
Bump chart examples
Basic example:
A more advanced example:
Click here for code to the plot above
Flags could be used instead of names:
Click here for code to the plot above
Sigmoid curves examples
With
geom_sigmoidyou can make custom sigmoid curves:Click here for code to the plot above
With
geom_sigmoidyou have the flexibility to make more complex plots:Click here for code to the plot above
Tutorial
Prep
Load packages and get some data with rank:
To create a ranking column we use
rankfrom base R. We specifyties.method = "random"to make sure that each country have different rankings if they have the same value.Make a bump chart
Most simple use case:
Pimp the bump chart!
Improve the bump chart by adding:
theme_minimal_grid()fromcowplot.wesanderson.smoothto 8. Higher means less smooth.geom_bump with factors (development version only)
You can use
geom_bumpwith factors or character as x axis. Just remember to keep an eye on factor order.Feedback
If you find any error or have suggestions for improvements you are more than welcome to contact me :)