I have 10 ggplot graphs that were created using for-loops. I would like to annotate the graphs, but the Y position changes for each graph (x position remains the same).
Y axis on graph 1 runs from 2-8
Y axis on graph 2 runs from 800-1400 etc.
My code looks like this:
Col_loop <- c("V", "Cr", "Co", "Ni", "Cu", "Zn", "Sr", "Cd", "Ba", "Pb")
for (i in col_loop){
print(i)
plot <- ggplot(dat, aes_string(x = "Time", y= i)) +
geom_point(size = 1)+
geom_line(size = 0.5)+
geom_text(x=5, y=8, label="year", color = "red")
print(plot)
}
This works for graph 1 but doesn’t show up on graph 2 because the y axis is on a different scale. How do I get the annotation (geom_text) to consistently be at the top of the graph no matter what the Y axis is?