I am trying to align the leader lines from my annotations to their respective points. The points and their connecting lines have been jittered using position = position_jitterdodge(0.05), which the leader lines are not accounting for. Because I used nudge_y to align the labels in rows above and below the points I cannot also use the position = position_jitterdodge (0.05) argument in the geom_text_repel(). Does anyone know how I may go about getting these leader lines to line up with the jittered points, while still keeping the annotations in their current positions? The following is the code I am using and an image of my graph.
ggplot(data = LGR_Data, aes(x = Proj_Year, y = Max_Tidbit_Temp, group = PermID, color = `CTRL/LOGJ`, shape = `CTRL/LOGJ`, fill = `CTRL/LOGJ`)) +
geom_line(linetype = "dotted", size = 0.5, position = position_jitterdodge(0.05)) + geom_point(size = 2, position = position_jitterdodge(0.05)) + geom_text_repel(data = subset (LGR_Data, Max_Tidbit_Temp > 23), aes(label = PermID), size = 1, nudge_y = 28 - subset(LGR_Data, Max_Tidbit_Temp > 23)$Max_Tidbit_Temp, direction = "x", angle = 45) +
geom_text_repel(data = subset (LGR_Data, Max_Tidbit_Temp < 23), aes(label = PermID), size = 1, nudge_y = 18 - subset(LGR_Data, Max_Tidbit_Temp <= 23)$Max_Tidbit_Temp, direction = "x", angle = 45)
I omitted a lot of formatting on the graph to minimize the length of the above code block.
Data.
LGR_Data <-
structure(list(PermID = c("PN1301", "PN1303", "PN1304",
"PN1310", "PN1313", "PN2124", "PN1307", "PN2124",
"PN2230", "PN2124"), Proj_Year = c(-1, -1, -1, -1, -1,
-3, -1, -2, -2, -1), CTRL/LOGJ = c("LOGJ", "LOGJ",
"LOGJ", "LOGJ", "LOGJ", "LOGJ", "LOGJ", "LOGJ",
"LOGJ", "LOGJ"), Max_Tidbit_Temp = c(23.857, 24.605,
24.002, 24.098, 24.243, 23.665, 24.026, 22.8, 22.824,
21.915)), class = c("tbl_df", "tbl", "data.frame"),
row.names = c(NA, -10L))