In a previous topic it was discussed how to draw an arrow in the middle of a segment
https://forum.posit.co/t/how-to-draw-an-arrow-in-the-middle-of-the-segment/7305
I would like to be able to do the same for a curve. The example below extends the previous one with the same approach for the geom_curve, however the result is not satisfactory.
Thank you!
b <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
df <- data.frame(x1 = 2.62, x2 = 3.57, y1 = 21.0, y2 = 15.0)
b1 <- b +
geom_segment(aes(x = (x1+x2)/2, y = (y1+y2)/2, xend = x2, yend = y2, colour = "segment"),
data = df) +
geom_segment(aes(x = x1, y = y1, xend = (x1+x2)/2 , yend = (y1+y2)/2, colour = "segment"),
arrow = arrow(),
data = df, show.legend=FALSE)
b1 + geom_curve(aes(x = (x1+x2)/2, y = (y1+y2)/2, xend = x2, yend = y2, colour = "curve"),data = df) +
geom_curve(aes(x=x1 , y = y1 , xend = (x1+x2)/2 , yend = (y1+y2)/2, colour = "curve"), arrow = arrow() , data = df)