Skip to content

Data Science Tutorials

For Data Science Learners

  • How To Become a Business Intelligence Analyst
    How To Become a Business Intelligence Analyst Course
  • computational gastronomy for data science
    Computational Gastronomy for Data Science Machine Learning
  • Top 10 Data Visualisation Tools
    Top 10 Data Visualisation Tools Every Data Science Enthusiast Must Know Course
  • How to Rank by Group in R?
    How to Rank by Group in R? R
  • How to perform MANOVA test in R
    How to perform the MANOVA test in R? R
  • Divide data into groups in R R
  • Replace first match in R R
  • Two-Way ANOVA Example in R
    Two-Way ANOVA Example in R-Quick Guide R
Rounded corner bar plot in R

How to make a rounded corner bar plot in R?

Posted on May 14May 14 By Admin No Comments on How to make a rounded corner bar plot in R?

Rounded corner bar plot in R, we’ll show you how to use the ggchicklet package in the R programming language to make a ggplot2 bar chart with rounded bars.

The ggchicklet Package: An Overview

Bob Rudis’ ggchicklet package includes utilities for creating rounded rectangle segmented column charts (often known as “chicklets”).

Let’s dive into the topic.

Example 1: Barplot with Round Corners in R

We’ll teach you how to make rounded-corner barplots in R using the ggplot2 and ggchicklet package.

We must first create some data for this example.

df <- data.frame(value = 1:5,
                    group = LETTERS[1:5])
df
  value group
1     1     A
2     2     B
3     3     C
4     4     D
5     5     E

We constructed a data frame with a numeric and a character column by running the prior code.

The ggplot2 package must then be loaded.

How to Use the Multinomial Distribution in R?

install.packages("ggplot2")                 
library("ggplot2")                               

We can now use the geom col method to create a conventional ggplot2 barplot, as illustrated below.

ggplot(data1, aes(group, value)) +      
geom_col()

 The barchart depicted in Figure 1 was constructed after executing the previous R programming code.

The corners of the bars are not yet rounded, as you can see.

We must also install and load the ggchicklet package in order to produce a bar graph with round corners.

install.packages("ggchicklet", repos = "https://cinc.rud.is")
library("ggchicklet")

We can now construct a barplot with round corners using the ggchicklet package’s geom chicklet function.

The radius argument in the geom chicklet function can be used to indicate how round the corners should be.

Rejection Region in Hypothesis Testing

ggplot(data1, aes(group, value)) + 
geom_chicklet(radius = grid::unit(3, "mm"))

As you can see, we’ve made another ggplot2 barplot, but this time we’ve rounded the edges of the bars.

Example 2: Stacked ggplot2 Barplot with Round Corners

When developing stacked barplots, we think rounded corners seem particularly petty.

To demonstrate this, we must first construct a new data set.

df2 <- data.frame(value = 1:16,
                   group = rep(LETTERS[1:4], each = 4),
                   sub = letters[1:4])
df2
   value group sub
1     1     A   a
2     2     A   b
3     3     A   c
4     4     A   d
5     5     B   a
6     6     B   b

The outcome of the previous code is shown above: A data frame with group and subgroup columns, as well as a values column.

Best Data Science YouTube Tutorials Free to Learn

The geom chicklet function can then be used to create a stacked barplot of these data. Note that the fill parameter is also specified within the aesthetics of our plot.

ggplot(df2, aes(group, value, fill = sub)) +  
geom_chicklet(radius = grid::unit(3, "mm"))

Check your inbox or spam folder to confirm your subscription.

R

Post navigation

Previous Post: How to perform the Kruskal-Wallis test in R?
Next Post: Best Books to Learn R Programming

Related Posts

  • Add new calculated variables to a data frame and drop all existing variables
    Add new calculated variables to a data frame and drop all existing variables R
  • Correlation By Group in R R
  • What is bias variance tradeoff
    What is the bias variance tradeoff? R
  • Error-list-object-cannot-be-coerced-to-type-double
    Error-list-object-cannot-be-coerced-to-type-double R
  • Calculate the p-Value from Z-Score in R
    Calculate the p-Value from Z-Score in R R
  • Cross product of transpose of matrix in R R

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Best Prompt Engineering Books
  • Understanding Machine Learning and Data Science
  • Best Git Books
  • Top 5 Books to Learn Data Engineering
  • Mastering R Programming for Data Science: Tips and Tricks
  • About Us
  • Contact
  • Disclaimer
  • Privacy Policy

https://www.r-bloggers.com

  • YouTube
  • Twitter
  • Facebook
  • Course
  • Excel
  • Machine Learning
  • Opensesame
  • R
  • Statistics

Check your inbox or spam folder to confirm your subscription.

  • Tips for Data Scientist Interview Openings
    Tips for Data Scientist Interview Openings Course
  • Changing the Font Size in Base R Plots
    Changing the Font Size in Base R Plots R
  • how to create a hexbins chart in R
    How to create a hexbin chart in R R
  • Box Cox transformation in R
    Box Cox transformation in R R
  • Convert characters to time in R R
  • How to Calculate Lag by Group in R
    How to Calculate Lag by Group in R? R
  • Count Observations by Group in R
    Count Observations by Group in R R
  • The Uniform Distribution in R
    The Uniform Distribution in R R

Privacy Policy

Copyright © 2025 Data Science Tutorials.

Powered by PressBook News WordPress theme