teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
541 stars 33 forks source link

Support `arrow` argument in `geom_pointpath()`. #55

Closed teunbrand closed 2 years ago

teunbrand commented 2 years ago

Such that the line between two points can have arrows.

Note to self: be careful that also the coord_polar() case works.

teunbrand commented 2 years ago

This should now be possible:

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.1.1
library(ggh4x)

set.seed(0)
df <- data.frame(
  x = c(1:7, 1:5, 1:6),
  y = rnorm(7 + 5 + 6),
  g = rep(LETTERS[1:3], c(7, 5, 6))
)

ar <- arrow(ends = "both", type = "closed", length = unit(2, "mm"))

p <- ggplot(df, aes(x, y, colour = g, group = g)) +
  geom_pointpath(arrow = ar)
p

p + coord_polar()

Created on 2021-11-02 by the reprex package (v2.0.1)