I am trying to justify several legends in ggplot, but without any real success. If the legend is displayed correctly, outside the plot area (gray area). However, when you show the legends inside the plot area, the legends are centered (and I would like them to be left-aligned). I tried to execute this thread , but it still does not work properly.
My example:
library(ggplot2) ggplot(mtcars, aes(wt, mpg)) + geom_point(aes(colour = factor(cyl), size = qsec)) + geom_point(aes(colour = factor(cyl), size = qsec)) + theme(legend.justification = c(1,0), legend.position = c(1,0), legend.margin = unit(0,"lines"), legend.box = "vertical", legend.key.size = unit(1,"lines"), legend.text.align = 0, legend.title.align = 0)
source share