R Language - How to Create Bump Chart in R

in Educationlast month

In this post, we take a look at How to Create Bump Chart in R. There are multiple ways to create the bump chart and two packages that can be used - ggplot2 and ggbump. This plot is often used for variety of the data plotting topics based on the specific data sets.

Previously I explained how to create the Spine chart in R. There is very limited information on that topic but I thought it would be reasonable to write on this topic. It'd be reasonable to cover more in near future but that is about that now.

Make sure to use the RStudio IDE while following this tutorial as it would be easier to do and also you can focus on the code and data in that case. Also if you consider simplicity and getting your work done, you'd find it useful to use the RIDE.

I have created a video to give you an overview on How to Create Bump Chart in R. You should give this one a try.

Let's take a look at the RStudio and then we would be installing both the ggbump and the ggplot2 libraries in case if you wish to create the code specific to both of them.

So take a look at the libraries to call for below.


and once you are done with that you would need to get the data ready for using with this and so that you can easily plot the bump chart.


It should look something like this.


Next thing would be working on our data set. Because that is the most crucial part of getting it out on the chart.


Now the data was cleaned up using the knittr, pacman and the tibble packages. You can install them just in case.

Next thing would be making the chart out of the data.

pacman::p_load(tidyverse, cowplot, wesanderson)
df <- tibble(country = c("India", "India", "India", "Sweden", "Sweden", "Sweden", "Germany", "Germany", "Germany", "Finland", "Finland", "Finland"),
year = c(2011, 2012, 2013, 2011, 2012, 2013, 2011, 2012, 2013, 2011, 2012, 2013),
rank = c(4, 2, 2, 3, 1, 4, 2, 3, 1, 1, 4, 3))
ggplot(df, aes(year, rank, color = country)) +

So it would look something like this. You can check the code above.


That is it. Now that you have checked the code above. The same code can be found from the official R documentation too. You would be able to get the R Studio properly working on the right notes and have some good examples there.

I have also covered some of the new charts like waffle chart, venn diagram and few others. I think in near future I would be covering some more content as well. I am pretty sure there are some really good options out there that you can take a look at for drawing the plots using ggplot and few other library.

I have also covered this type of the chart using the Python. However as of now I have not covered this outside the live class. So I may have to make the tutorial and cover the same in the content that I can make use of in the youtube channel that I am hosting here. It would be pretty cool on that note.

I have decided to cover some of the tutorials which are specific to SPSS and Minitab however there seems to be limitations on my learning with Stats. So I need to follow some university specific approach so that I can cover some really good tutorials on these topics.

If you happen to like this content, do give me feedback over there and that would help me improve my efforts in near future.


Thanks for your contribution to the STEMsocial community. Feel free to join us on discord to get to know the rest of us!

Please consider delegating to the @stemsocial account (85% of the curation rewards are returned).

You may also include @stemsocial as a beneficiary of the rewards of this post to get a stronger support.