top of page

How to Plot Combo Chart in R Using ggplot2

laptop screening with written code

What is a Combo Chart?

combination chart, also known as a combo chart, is a powerful data visualization tool that merges two or more chart types into a single graphical representation. This allows for the comparison of different data sets, making it easier to identify trends and relationships across various categories over time.

Combination charts typically incorporate different types of charts, such as bar charts, line charts, and area charts, within the same visual. This feature enables the display of multiple data series simultaneously, facilitating effective comparisons.

How to Create a Combination Chart in R Using ggplot2

In this short article using the Sample – Superstore data, I will create different types of combo charts in R using ggplot2. But before that, lets load the required packages and data.

Load the required packages in your R session as shown below.

loading necessary packages in r

Set your working directory and load the Sample – Superstore dataset as shown below.

setting working directory and loading data in r

1. Line + Column Chart

To create a combo chart (Line + Column) comparing Sales and Profit by Month – you can use the following code.

code for creating combo chart in r (line + column chart)

Note: Sales values are represented as bars while the Profit values are represented as line chart.

Executing the above code plots the view below.

Example of combo chart (line+column)

2. Line + Clustered Column Chart

By making a few changes in the above code, you can create a combo chart (Line + Clustered Columns) comparing Sales and Profit by Weekday and Product Category using the following line of code.

code for creating combo chart in R (line + clustered column chart)

Note: The clustered bars compare the Sales by Category for different days of the week while the Profit values are presented by the line chart.

Executing the above code plots the view below.

example of combo chart (line + clustered column)

Note, you can replace the clustered bars with stacked bars by changing the position argument to “stack” as shown in the code below.

code for creating combo chart in r (line + stacked column chart)

Executing the above code plots the view below.

example of combo chart (line + stacked column chart)

3. Line + Area Chart

To create a combo chart (Line + Area Chart) comparing Sales and Profit by Month – you can use the following code.

code for creating combo chart in r (line + area chart)

Note: Sales values are represented by the area chart while Profit values are represented by the line chart.

Executing the above code plots the view below.

example of combo chart (line + area chart)

4. Area + Column Chart

By making a few changes in the above code, you can create a combo chart (Area + Column) comparing Sales and Profit by Month using the following line of code.

code for creating combo chart in r (area + column chart)

Note: Sales values are represented by the bars while Profit values are represented by the area chart.

Executing the above code plots the view below.

example of combo chart (area + column chart)

Conclusion

By leveraging combo charts, analysts and decision-makers can communicate insights more effectively, fostering better understanding and informed decision-making. Whether you are a seasoned data analyst or a business professional looking to enhance your presentations, incorporating combo charts into your toolkit can significantly elevate your data storytelling capabilities. 

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!

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

+254 738 307 495

East Gate Mall, Donholm

3rd Floor Suite No. 3i

Nairobi, Kenya

Join our mailing list

bottom of page