easy_change_legend: Easily modify legends

View source: R/legend.R

easy_change_legendR Documentation

Easily modify legends

Description

Change legend position, direction, or justification.

Usage

easy_change_legend(
  what = c("position", "direction", "justification"),
  to,
  teach = FALSE
)

easy_move_legend(
  to = c("right", "none", "left", "bottom", "top"),
  teach = FALSE
)

easy_legend_at(to = c("right", "none", "left", "bottom", "top"), teach = FALSE)

easy_rotate_legend(to = c("vertical", "horizontal"), teach = FALSE)

easy_adjust_legend(to = c("left", "right", "center"), teach = FALSE)

Arguments

what

legend component to modify ("position", "direction", or "justification")

to

to what to set the legend component should be changed

teach

print longer equivalent ggplot2 expression?

Details

Due to limitations of ggplot2 this will apply to all legends at once

Value

a theme object

Author(s)

Jonathan Carroll

Examples


library(ggplot2)

# Move legends to bottom
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() + easy_move_legend("bottom")

# Make legends horizontal
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() + easy_rotate_legend("horizontal")

# Justify legends to the bottom and justify to the right
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
  geom_point() +
  easy_move_legend("bottom") +
  easy_adjust_legend("right")

ggeasy documentation built on Nov. 3, 2024, 9:08 a.m.