library(ggplot2)
library(magrittr)
library(tidyr)
# Generate some dummy data
ten.points <- data.frame(line.no = rep(1:5, each = 2), x = runif(10), y = runif(10),
position = rep(c("start", "end"), 5))
five.segments <- ten.points %>% pivot_wider(names_from = position, values_from = c(x,y))
# Ten percent off the start and end
ggplot(five.segments) +
geom_point(data = ten.points, aes(x = x, y = y)) +
geom_arrowsegment(aes(x = x_start, xend = x_end, y = y_start, yend = y_end),
position = position_attractsegment(start_shave = 0.1, end_shave = 0.1))
# Absolute distance of 0.02 at the end only
ggplot(five.segments) +
geom_point(data = ten.points, aes(x = x, y = y)) +
geom_arrowsegment(aes(x = x_start, xend = x_end, y = y_start, yend = y_end),
position = position_attractsegment(end_shave = 0.02,
type_shave = "distance")) +
coord_fixed()
Run the code above in your browser using DataLab