library(ggplot2)
# Basic usage
ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
geom_point() +
legend_left()
# Works with multiple legends
ggplot(mtcars, aes(mpg, wt, color = factor(cyl), shape = factor(am))) +
geom_point(size = 3) +
legend_left()
# 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