I would like to use ggplot to create a complex plot, and then at the very end, I would like to add the word "Draft" to it. But I would like this word to be on the back, and not on the front. I know that I can have it in the back just adding it first, but that’s not what I want. The reason is because I want to write a custom save function that adds the name of the source file used to create the shape to the x axis and also marks the number as “Draft” if a certain flag is not set. My custom function does this, but the word "Draft" is always ahead.
Is there a way to fine-tune only the annotated line below, keeping the order the same that would lay out a draft for a sine wave?
x = seq(0,100,.1)
d = data.frame(x=x,y=sin(x))
p = ggplot(data=d,aes(x=x,y=y)) + geom_line(size=3,color="grey50")
p = p + annotate("text",x=50,y=0,label="Draft",color="blue",size=40)
print(p)
ggsave(filename = "test_background.pdf")

source
share