library(ggplot2)
# Basic usage
ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
geom_point() +
legend_bottom()
# Aligned to full plot
ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
geom_point() +
labs(title = "My Plot Title") +
legend_bottom(align_to = "plot")
# Position only the colour legend at bottom
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