How to make a rounded corner bar plot ?

You can't easily do this in ggplot, because rounded lines extend beyond the normal "limits" of the line:

ggplot(mtcars, aes(x = factor(cyl), xend = factor(cyl), yend = stat(count) - stat(count))) + 
    stat_count(geom = 'segment', size = 50)

Rplot

ggplot(mtcars, aes(x = factor(cyl), xend = factor(cyl), yend = stat(count) - stat(count))) + 
    stat_count(geom = 'segment', size = 50, lineend = 'round')

Rplot01

1 Like

You might find @hrbrmstr's ggchicklet package helpful. Cheers!

library(tidyverse)
library(ggchicklet)

ggplot(count(mtcars, cyl), aes(x = cyl, y = n)) +
  geom_chicklet(radius = grid::unit(15, 'mm'), fill = 'skyblue') +
  theme_minimal()

Created on 2019-07-10 by the reprex package (v0.3.0.9000)

2 Likes

Thank you :grinning:

Thank you :grinning:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.