How to Create a Circular Bar Plot in R with ggplot2
top of page

How to Create a Circular Bar Plot in R with ggplot2

laptop on a table, phone, and a cup of coffee

Overview

A circular bar chart is a type of bar chart plotted in a polar coordinate system, where bars radiate outward from a central point. This type of visualization is often used when there's a need to represent categorical data in a visually unique way, while still maintaining the clarity of a bar chart.

Example of a Circular Bar Plot

example of a circular bar plot

Step-by-step Guide

To create a circular bar plot, load the required libraries.

loading libraries in r

Set your working directory (default folder where R looks for files to read or save) and load the dataset.

setting working directory and loading dataset

Using as.yearmon() function from the Zoo library and month() function from lubridate library, extract the Month-Year and Month as strings, using the code below.

r code computing months as strings

See the resulting dataset.

sample dataset

Next, compute the sales by month-year, then calculate the labels by merging the month-year and sales values – lastly compute the id’s, using the code below.

r code grouping sales by months

See the resulting dataset.

sample dataset

Create a circular bar plot using the code below.

r code on how to create a circular bar plot

Note: The y-axis limit has been set as -50,000 to 120,000 (you can use these values to set the limit of your plot).  

Executing the above code generates the view below.

example of a circular plot in r

Labelling the Circular Bar Plot

Create data frame for labels using the code below.

r code on labelling circular bar plot

Add labels to the view using the code below.

adding labels to circular bar plot in r

Executing the above code generates the view below.

example of a labelled circular bar plot in r

Stacked Circular Bar Plot

Using the same dataset, you can create a stacked circular bar plot using the code below.

r code on how to create a stacked circular bar plot

Executing the above code generates the view below.

example of a stacked circular bar plot

Grouped Circular Bar Plot

Using the same dataset, you can create a grouped circular bar plot showing Sales by Month and Category using the code below.

r code on how to create a grouped circular bar plot

Executing the above code generates the view below.

example of a grouped circular bar plot

Conclusion

Circular bar plots provide a visually striking way to represent categorical data while making efficient use of space. They can be especially useful for displaying data with a cyclic nature, such as time-based trends or periodic patterns. While they may not always be the best alternative to traditional bar charts, they add versatility to data visualization and can enhance storytelling when appropriately applied. By leveraging R’s powerful plotting libraries, users can customize circular bar plots to suit their needs and create compelling visualizations that make their data more engaging and accessible.

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