5  More tips and tricks

Code
# Load required packages
library(tidyverse)

This chapter is about a few random things that may come in handy when creating plots. There are a few things that you probably always have to Google to remind yourself how to do it. This chapter is about those kinds of things.

5.1 Removing the legend

You can remove the legend by using the guides() element. Simply set the aesthetic that you don’t want a legend of to "none".

Code
data <- tibble(x = 1:5, y = 1:5)
ggplot(data, aes(x, y, fill = factor(x))) +
  geom_col() +
  guides(fill = "none") +
  theme_minimal()