Easily position the ggplot legend
legend_positions.RdQuick functions to enable faster and more readable theme adjustments to ggplot2 when positioning the legend. Functions provided are:
'legend_none' disables the legend for a plot
'legend_top' puts the legend in the top position
'legend_bottom' puts the legend in the bottom position
'legend_left' puts the legend in the left position
'legend_right' puts the legend in the right position
Examples
library(ggplot2)
ggplot(mtcars, aes(x = mpg, y = hp, colour = factor(cyl))) +
geom_point() +
legend_none()
ggplot(mtcars, aes(x = mpg, y = hp, colour = factor(cyl))) +
geom_point() +
legend_top()
ggplot(mtcars, aes(x = mpg, y = hp, colour = factor(cyl))) +
geom_point() +
legend_bottom()