Skip to contents

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

Usage

legend_horizontal()

Value

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

Examples

library(ggplot2)

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