Skip to contents

Remove specific legends from a plot while keeping others. This is more targeted than legend_none() which removes all legends.

Usage

legend_hide(...)

Arguments

...

Aesthetic names (unquoted) to hide. Common values: colour, fill, size, shape, linetype, alpha. Note: color is automatically converted to colour.

Value

A guides specification that can be added to a plot.

Examples

library(ggplot2)

# Plot with multiple legends
p <- ggplot(mtcars, aes(mpg, wt, color = factor(cyl), size = hp)) +
  geom_point()

# Hide the size legend
p + legend_hide(size)

# Hide multiple legends
p + legend_hide(size, colour)