• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Python Viz
  • Seaborn
  • Altair
  • R Viz
  • ggplot2
  • About
    • Privacy Policy
  • Show Search
Hide Search

How to Make Barplots with rounded edges in ggplot

datavizpyr · June 17, 2022 ·

In this tutorial, we will learn how make bar plots with rounded edges in ggplot. We will use ggplot2 extension package called ggchicklet developed by the fantastic R developer boB Rudis/hrbrmstr.

Let us get started by installing ggchicklet and loading tidyverse.

remotes::install_git("https://git.sr.ht/~hrbrmstr/ggchicklet")
library(ggchicklet)
packageVersion(ggchicklet)

## [1] '0.5.2'

We have installed ggchicklet version 0.5.2. Let us quickly generate data for making a simple barplot. We use palmer penguins data set to compute average body mass per species.

df <- penguins %>% 
  group_by(species) %>%
  summarize(body_mass=mean(body_mass_g, na.rm=TRUE))

df
## # A tibble: 3 × 2
##   species   body_mass
##   <fct>         <dbl>
## 1 Adelie        3701.
## 2 Chinstrap     3733.
## 3 Gentoo        5076.

And we will this simple data and make barplot using geom_col().

df %>% 
  ggplot(aes(x=species, y=body_mass, fill=species))+
  geom_col()
ggsave("barplot_ggplot.png")

As one can barplots made with ggplot2 has rectangle edges.

barplot with default rectangle edges
barplot with default rectangle edges in ggplot2

As Bod Rudis puts it

Sometimes it is useful to stylize column charts a bit more than just bland rectangles.

ggchicklet, a ggplot2 extension package has geom_chicklet() that makes rounded edge bars. We use default grey background to highlight the white line highlighted around the bars by ggchicklet..

df %>%
  ggplot(aes(x=species, y=body_mass, fill=species))+
  geom_chicklet()
barplot with rounded edge bars in ggplot2 with ggchicklet
barplot with rounded edge bars in ggplot2 with ggchicklet

If we are interested in making horizontal barplot with rounded bars, we can not use ggplot2 v2.3 feature of swapping x and y axes. This would give the following error.

df  %>%
  ggplot(aes(x=body_mass, y=species, fill=species))+
  geom_chicklet()
## Warning: Stacking not well defined when not anchored on the axis
## Warning: position_stack requires non-overlapping x intervals

However, we can use coord_flip() to make the horizontal barplots with rounded edges.

df  %>%
  ggplot(aes(x=species, y=body_mass, fill=species))+
  geom_chicklet()+
  coord_flip()
Horizontal Barplots with rounded edges ggchicklet
Horizontal Barplots with rounded edges ggchicklet

Related posts:

How to Make Heatmap with ggplot2?How To Make Simple Heatmaps with ggplot2 in R? Stacked Barplots Side By Side with ggplot2 in RHow to Make Horizontal Stacked Barplots with ggplot2 in R? Scatter Plot R: Fill color by variableHow To Color Scatter Plot by Variable in R with ggplot2? How to Align Title Position in ggplot2?How To Adjust Title Position in ggplot2 ?

Filed Under: R Tagged With: barplot with rounded edge bars, ggchicklet rounded edge

Primary Sidebar

Tags

Altair barplot Boxplot boxplot python boxplot with jiitered text labels Bubble Plot Color Palette Countplot Density Plot Facet Plot gganimate ggplot2 ggplot2 Boxplot ggplot2 error ggplot boxplot ggridges ggtext element_markdown() Grouped Barplot R heatmap heatmaps Histogram Histograms Horizontal boxplot Python lollipop plot Maps Matplotlib Pandas patchwork pheatmap Pyhon Python R RColorBrewer reorder boxplot ggplot Ridgeline plot Scatter Plot Scatter Plot Altair Seaborn Seaborn Boxplot Stock Price Over Time Stripplot UpSetR Violinplot Violin Plot World Map ggplot2

Buy Me a Coffee

Copyright © 2025 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version