I have a plot made with ggplot2 and I'd like to get the legend positioned in the top left corner.
legend.position = "top"
gets me a legend positioned above the plot, but centered:
legend.position = c(0,1)
gets the legend in the top left, but it floats over the other plot elements:
Know how to get that legend up in the top left without having it float? I tried declaring the legend height, but no dice. Do I have to adjust the size and position of the title and plot area?
Thanks!
legend.justification=c(1,1)
- for example,p + theme(legend.position=c(1,1), legend.justification=c(1,1))
. Since this will still be plotting in the graphics area, you may also want to play around withlegend.background=element_blank()
andlegend.key=element.blank()
. – JasonAizkalnslegend.justification
is helpful in positioning the legend just right, but it floats over the graphics area. I'd like to get the legend out of the graphics area, likelegend.position = "top"
does so nicely. – Conor Gaffney