Create bumbplot with ggbump


The ggbump package in R is an extension of the ggplot2 package, designed to simplify the process of building bump plots.
This post showcases the key features of ggbump and provides a set of graph examples using the package.

Documentation

{ggbump}

Quick start


The ggbump package in R is an extension of the ggplot2 package, designed to create bump plots, which is a variant of the parallel coordinates plot

It offers a geom_bump() function that creates bump plots with ggplot2. The package is particularly useful for visualizing ranked data and ranking changes over time.

✍️ author → David Sjoberg

📘 documentationgithub

⭐️ more than 500 stars on github

Installation


To get started with ggbump, you can install it directly from CRAN using the install.packages function:

install.packages("ggbump")

Basic usage


We start by creating a simple dataset with three columns: year, revenue, and company.

year <- rep(2019:2021, 3)
revenue <- c(
  100, 200, 300,
  150, 250, 100,
  200, 300, 400
)
company <- c(
  "Company A", "Company A", "Company A",
  "Company B", "Company B", "Company B",
  "Company C", "Company C", "Company C"
)
df <- data.frame(
  year = year,
  revenue = revenue,
  company = company
)

Next, we create a ggplot object using the df dataset and the geom_bump function from ggbump.

ggplot(df, aes(x = year, y = revenue, color = company)) +
  geom_bump()

Key features


→ Individual points

You can easily combine geom_bump() with geom_point() to display individual points on the plot.

Example:

ggplot(df, aes(x = year, y = revenue, color = company)) +
  geom_bump(size=2) +
  geom_point(size=5)


→ Custom style

ggbump allows you to customize the appearance of your bump plot using various arguments and ggplot2 themes.

Example:

ggplot(df, aes(x = year, y = revenue, color = company)) +
  geom_bump(size=1.5) +
  geom_point(size=4) +
  scale_color_brewer(palette = "Accent") +
  theme_minimal()




❤️ 10 best R tricks ❤️

👋 After crafting hundreds of R charts over 12 years, I've distilled my top 10 tips and tricks. Receive them via email! One insight per day for the next 10 days! 🔥