thomasp85 / ggforce

Accelerating ggplot2
https://ggforce.data-imaginist.com
Other
917 stars 105 forks source link

Radius for geom_shape only on alternate corners #242

Closed Jimbilben closed 9 months ago

Jimbilben commented 3 years ago

Is there a way to make the radius argument in geom_shape to apply to both 'inside' and 'outside' corners of a shape? When something like a step shape is used, only alternate corners get rounded. It seems like the curve for the shape needs to be able to both expand and contract from the basic shape to get curves on every step:

test <- tibble(x = c(.5, 1.5, 1.5, 2.5, 2.5, 3.5, 3.5, 4.5, 4.5, 5.5, 5.5, .5,
             4.5, 4.5, 5.5, 5.5, 6.5, 6.5, 7.5, 7.5, 8.5, 8.5, 9.5, 9.5, 10.5, 10.5, 11.5, 11.5, 12.5, 12.5, 11.5, 11.5, 10.5, 10.5),
       y = c(9, 9, 7, 7, 5, 5, 3, 3, 1, 1, 0, 0,
             15, 13, 13, 11, 11, 9, 9, 7, 7, 5, 5, 3, 3, 1, 1, 0, 0, 11, 11, 13, 13, 15),
       id = c(rep("a", 12),
              rep("b", 22)))

ggplot(data = test) +
  geom_shape(aes(x = x, y = y, group = id), fill = "grey50", linetype = "blank", alpha = .1, radius = unit(8, "points"))
thomasp85 commented 2 years ago

I'm aware of this issue - it is basically a matter of how polyclip works and I haven't found a good way around it