I would like to put vertical lines and labels for the vertical lines for each graph in a loop. the position of the line is saved in a dataframe "grid".
Although the position of the line seems correct the label value and its position is off. My question is why.
library(ggplot2)
library(grid)
library(gridExtra)
plots <- list()
grid <- data.frame(x=seq(4), y=c(200, 400, 600, 800))
for (i in 1:4) {
V1 <- rnorm(1000)
V2 <- seq(1000)
df <- data.frame(V1, V2)
plots[[i]] <- ggplot(df, aes(x= V2, y=V1)) +
geom_point() +
geom_vline(xintercept = grid[i,2], color="red")+
geom_text(aes(x=grid[i,2], label=grid[i,2], y=3))
}
grid.arrange(grobs=plots, nrow=2)



