top of page

Visualizing Rank Over Time: Creating Bump Charts in R

an image of keyboard, coffee cup, a phone and a pen on the table

Overview

A bump chart is a data visualization tool specifically designed to display how the rankings of different categories or entities change over time or across another sequential dimension. Unlike standard line charts that focus on the magnitude of values, bump charts emphasize the relative position (rank) of each item at each point in time, making them ideal for tracking and comparing changes in rank rather than actual values

Example of a Bump Chart

example of a bump chart
Replicate the visualization: Link to code

Step-by-Step Guide

Load the required libraries.

# load libraries
library(tidyverse)
library(paletteer)

Load dataset.

# load data
superstore<-read.csv("https://raw.githubusercontent.com/bernardkilonzo-rigor/dataviz/main/data/Sample%20-%20Superstore.csv")

Compute rankings.

# computing rankings
Rank_data<-superstore%>%
  mutate(mon = month(Order.Date, label = TRUE))%>%
  group_by(mon,Region)%>%
  summarise(sales =round(sum(Sales),0))%>%
  mutate(rank =dense_rank(desc(sales)))

Prepare labels.

# Adding labels
Rank_data$label<-paste0(Rank_data$rank,"-",Rank_data$Region,"~",Rank_data$sales)

Create a basic bump chart.

# creating a basic plot
Rank_data%>%ggplot(aes(x = mon, y = rank, group =Region, color =Region))+
  geom_line(linewidth = 1.0)+
  geom_point(size =5)+
  scale_y_reverse()

See the resulting view.

example of a bump chart

Formatting and customizing the plot.

# formatting & customizing the bump chart
Rank_data%>%ggplot(aes(x = mon, y = rank, group =Region, color =Region))+
  geom_line(linewidth = 1.0)+
  geom_point(size =5)+
  scale_y_reverse()+
  geom_text(data = Rank_data%>%filter(mon=="Jan"), aes(label = label), hjust=0.1,vjust=-1, size =3)+
  geom_text(data = Rank_data%>%filter(mon=="Dec"), aes(label = label), hjust=0.7,vjust=-1, size =3)+
  scale_color_paletteer_d("PrettyCols::Autumn")+
  labs(title = "Ranking Sales Performance by Region",
       caption = "Viz by: Bernard Kilonzo",
       x = "Months", y = "Rank")+
  theme(panel.background = element_blank(),
        axis.text.y = element_blank(),
        axis.ticks = element_blank(),
        axis.title = element_blank(),
        axis.title.y = element_blank(),
        axis.title.x = element_text(family = "serif", size = 9, color = "gray35"),
        axis.text.x = element_text(family = "serif", size = 9, color = "gray35"),
        legend.position = "none",
        plot.title = element_text(family = "serif", face = "bold", size = 12, colour = "gray25"),
        plot.caption = element_text(family = "serif", face = "italic", size = 9, color = "gray35"))

See the resulting view.

example of a bump chart
Build similar viz in Tableau: Explore how to create a bump chart in Tableau

Conclusion

Bump charts offer a visually compelling way to explore changes in rankings over time - an ideal solution for datasets where position matters more than raw values. Whether you're analyzing sports team standings, brand popularity, or product performance, bump charts highlight the dynamic interplay between competing entities in a way that's both intuitive and engaging.

By using R, particularly the flexibility of ggplot2, you gain precise control over design, customization, and interactivity. With just a few lines of code, you can transform a simple dataset into a meaningful visual story of how ranks evolve - complete with line crossovers, labelled paths, and contextual annotations.

Mastering bump charts not only enhances your data storytelling toolkit but also deepens your understanding of relative patterns and temporal shifts. As the world becomes increasingly data-driven, tools like these empower analysts, educators, and decision-makers to reveal trends that traditional charts might miss.

If you like the work we do and would like to work with us, drop us an email on our contacts page and we’ll reach out!

Thank you for reading!

Tags:

 
 
Original.png

We Support You Deliver Business-Focused Solutions That Enable Data-Driven Decision Making.

  • Tableau profile
  • YouTube
  • White LinkedIn Icon
  • Facebook
  • X

QUICK LINKS

CONTACT US

WhatsApp: +254 738 307 495

East Gate Mall, Donholm

3rd Floor Suite No. 3i

Nairobi, Kenya

Join our mailing list

bottom of page