Learn R Programming

ggguides (version 1.1.4)

legend_horizontal: Set Legend Direction to Horizontal

Description

A one-liner to arrange legend keys horizontally. Useful for legends placed at the top or bottom of a plot.

Usage

legend_horizontal()

Arguments

Value

A ggplot2 theme object that can be added to a plot.

See Also

legend_vertical, legend_top, legend_bottom

Examples

Run this code
library(ggplot2)

# Horizontal legend at bottom
ggplot(mtcars, aes(mpg, wt, color = factor(cyl))) +
  geom_point() +
  legend_bottom() +
  legend_horizontal()

Run the code above in your browser using DataLab