ggchicklet
ggchicklet copied to clipboard
Semi-Rounded Bars (draw a rounded top instead of all sides)
Hi, First, thanks a lot for the nice package. Is it possible to implement a way to choose a specific side of a rectangle to become rounded? Something like this in chart.js: https://codepen.io/jordanwillis/pen/jBoppb (from https://stackoverflow.com/a/43281198/9555505)
Actually, I have done that by a hacky trick of mixing geom_bar and geom_chicklet:
df <- data.frame(
year = c(2015, 2016, 2017, 2018, 2019, 2020),
value = c(46, 49, 53, 63, 72, 81) # for the geom_chicklet that is rounded
)
df$value2 <- df$value/4 # for the geom_bar that is non-rounded
ggplot(df, aes(x = factor(year), y = value), fill = "#56c7da") +
geom_chicklet(
inherit.aes = FALSE,
aes(x = factor(year), y = value),
fill = "#56c7da",
color = "#56c7da",
radius = grid::unit(3, 'mm'),
position = position_dodge(),
width = 0.5,
size = 0
) +
geom_bar(
inherit.aes = FALSE,
aes(x = factor(year), y = value2),
stat = "identity",
fill = "#56c7da",
position = position_dodge(),
width = 0.5,
size = 0
) +
scale_y_continuous(expand = c(0, 0), limits = c(0, 100)) +
xlab("year") +
ylab("score")
However, I was wondering if you could mind implementing a built-in argument to handle such a visualization feature?
Agreed, this would be a nice addition to this package.