I would like to be able to put text below a legend. Here is a sample that I found online:
library(ggplot2) library(grid) library(gtable) # The label label = "Mean of Sepal.Width = 3.05" # The plot - Note the extra margin space for the label myplot = ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width, color=Species)) + geom_line() + annotate("text", x = Inf, y = 2.9, label = label, hjust = -0.08, size = 3) + theme(plot.margin = unit(c(.5,6,.5,.5),"lines"), legend.background = element_rect(colour = "black")) # Turn off clipping to the plot panel g = ggplotGrob(myplot) g$layout$clip[g$layout$name == "panel"] = "off" grid.draw(g)
This is great, but you have to have the Y value. I would like to have this update automatically for the particular plot. Also, I do not need a box around the legend.
Thanks for any help!