thomasp85 / ggforce

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

Feature request: `geom_elbow()` #324

Open fmarotta opened 1 month ago

fmarotta commented 1 month ago

Hi! I was looking for a geom that connects two points with an elbow, similar to ggplot2::geom_step() and ggraph::geom_edge_elbow(), but with x, y, xend, yend aesthetics. I tried to open an issue in ggplot2 but this feature is better suited for an extension package. I think it would fit well in ggforce, given that there are already geom_link() and geom_diagonal(). It would look something like this and I am happy to prepare a merge request, if you are interested.

test <- data.frame(
  x = 1,
  y = 1,
  xend = 2,
  yend = 2,
  direction = "vh"
)
ggplot(test, aes(x = x, y = y, xend = xend, yend = yend, direction = direction)) +
  geom_elbow()

geom_elbow