I\'d like to create a geom_path() that has arrows pointing towards the next location in the path.
I can get the path to plot, without issue, for example:
geom_segment
has an arrow
argument. Here's a short example:
library(grid) # needed for arrow function
p <- ggplot(df, aes(x=x, y=y)) +
geom_point() +
geom_segment(aes(xend=c(tail(x, n=-1), NA), yend=c(tail(y, n=-1), NA)),
arrow=arrow(length=unit(0.3,"cm")))
library(grid)
is needed for arrow()
function, see here.