9 Bump Chart 1
Chapter section list
9.1 Introduction
Besides absolute score values the RWB dataset has also included information about the ranks of the different countries. This wouldn’t be necessary as one could compute from the score values the relative country position. But traditionally the ranks are the most important parameter to compare the different countries. The rank is the only value that is available for all years, starting with the first year 2002 of the World Press Freedom Index (WPFI).
Measured parameters and methodology has changed during 2002 several times, so that there is no comparison possible of the calculated abolute values for all years. The only parameter that was constant over all the years is the rank of the countries, their relative position in a field of currently 180 evaluated countries. The index started 2002 with 139 countries, reached 180 in 2014 and remained constant until today (2025).
R Code 9.1 : Number of countries evaluated per year for the World Press Freedom Index (WPFI)
Code
#> # A tibble: 23 × 2
#> year_n n
#> <dbl> <int>
#> 1 2002 139
#> 2 2003 166
#> 3 2004 167
#> 4 2005 167
#> 5 2006 168
#> 6 2007 169
#> 7 2008 173
#> 8 2009 175
#> 9 2010 178
#> 10 2012 179
#> 11 2013 179
#> 12 2014 180
#> 13 2015 180
#> 14 2016 180
#> 15 2017 180
#> 16 2018 180
#> 17 2019 180
#> 18 2020 180
#> 19 2021 180
#> 20 2022 180
#> 21 2023 180
#> 22 2024 180
#> 23 2025 180
9.2 Structure of Bump Charts
It is possible to use the normal line chart to display the ranking developments of several countries as I have done as an experiment for the World Happiness Report (WHR) in Rank changes for Countries in Western Europe 2011-2024. The only adaption of the line chart was to reserve the scale so that the lowest figures (= the best rankings) are at the top of the graphic.
But it turned out, that with {ggbump} there is a special R packages for ranking charts. It creates a ggplot()
that makes a smooth rank over time. Bump charts are not only good to use to plot ranking over time, but can also be used when the path between two nodes have no statistical significance.
It is typical of bump charts that
- they have points over the lines,
- no legends but
- texts on the vertical sides of the plot to display the change in the rankings.
Two contrasts:
- In contrast to line charts, or connected scatterplots which show the evolution of the absolute values over time, bump charts indicate the changes in the relative position of the evaluated categories.
- In contrast to a sorted lollipop chart which also contains a numerical variable and a categorical variable and shows the ranking situation through a comoarison of their length representing the absolute value in a given moment (year), bump charts show the changes in the relative position of the categories over time.
As the drawing of bump charts needs {ggbump}, a program of the {ggplot2} universe, I can’t use the native plotly::plot_ly()
approach but have to use plotly::ggplotly()
.
Resource 9.1 : Bump Chart
After a short internet research I found the following resources on bump charts. I have ordered it from the easiest illustration with imaginary data to the more complex examples with real data:
-
Bump chart in {ggplot2} with {ggbump}: This is very nice step-by-step tutorial with imaginary data. It starts by
- the most basic bump chart, then
- it is adding points and
- colors and finally
- it is adding the texts on the vertical sides of the plot to display the change in the rankings. -Bump chart with {ggplot2}: This page with imaginary does not mention the {ggbump} package but it explains some basci techniques for bump charts as
ggplot2::scale_y_reverse()
and adding chart labels.
-
R-Graph Gallery has four articles with increasing complexity on bump charts:
- Basic bump plot explains how to build a basic bump plot with R. It uses the {ggbump} package, provides reproducible code and explains how input data must be formatted.
- Create bumbplot with ggbump is another basic introduction with has collected at the end some links of bump chart examples.
- Customized bump plot explains how to change colors, and adding labels and title.
-
Bump plot with highlights is the most complex article. It shows
- how to change the order and adding individual points
- how to change the theme and adding annotations
-
Bump it Up: Creating a Bump Chart in R: Provides a nice but complex example with
- data exploration,
- data pre-processing,
- adding image data (logoi of the soccer clubs, but could be in my use case country flags)
- basic plot
- scales & labels
- finishing touches
- Bump Chart: Track performance over time: A complex article that demonstrates the power of bump charts with data from the 2018 Olympic Winter Games in PyeongChang.
- ggbump repo: It is the GitHub repository for the {ggbump} package. The README has some examples but — with the exception of the first illustration — they are all very complex and not suitable for step-by-step introduction or tutorial. The code for the first example is partly taken from the package online help but has additonal features not documented with code.
Step-by-Step Guide for Building Bump Charts in Plotly: This article is written for Python and is therefore not direct applicable for my R coding. But it shows some interesting new ideas that are not contained in the above R code examples:
- Comparing the rankings for only two years with straight lines. It has the effect that it is much easier to follow the lines and detect the differences. The graphics needs therefore only labels of the right side of the figure. Besides this kind of bump chart would not need the {ggbump} package.
- Adjusting the marker size in relation to the absolute value of the measure taken for the ranking. This is an interesting feature that shows not only the change in the ranks but also in the values.
- Adding the rank number inside the markers. This saves space and would not need a Y axis any more.
9.3 Bump Chart Step-by-Step
For a demonstration of bump charts I will take as data the top ten RWB countries form 2025.
R Code 9.2 : Data frame of the top ten RWB countries
Code
rwb <- readRDS(paste0(here::here(), "/data/chap011/rwb/rwb.rds"))
vec_top_ten_2025 <- rwb |>
dplyr::filter(year_n == 2025) |>
dplyr::arrange(rank) |>
dplyr::slice_head(n = 10) |>
dplyr::pull(country_en) |>
as.character()
vec_top_ten_2025
Code
my_save_data_file("chap091", vec_top_ten_2025, "vec_top_ten_2025.rds")
#> [1] "Norway" "Estonia" "Netherlands" "Sweden" "Finland"
#> [6] "Denmark" "Ireland" "Portugal" "Switzerland" "Czechia"
9.3.1 Most basic bump chart
R Code 9.3 : Evolution of the rankings of the top ten countries in 2025