library(ggplot2)
# Basic usage — legend centered vertically on the left
ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
geom_point() +
legend_left()
# Pin legend to the top of the left rail
ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
geom_point() +
legend_left(justification = "top")
# Position only the colour legend on the left
ggplot(mtcars, aes(mpg, wt, color = factor(cyl), size = hp)) +
geom_point() +
legend_left(by = "colour") +
legend_bottom(by = "size")
Run the code above in your browser using DataLab