library(ggplot2)
# Basic usage
ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
geom_point() +
legend_right()
# Position only the size legend on the right
ggplot(mtcars, aes(mpg, wt, color = factor(cyl), size = hp)) +
geom_point() +
legend_bottom(by = "colour") +
legend_right(by = "size")
Run the code above in your browser using DataLab