scale_manual question in ggplot2

fcyl <- factor(mtcars$cyl)
fam <- factor(mtcars$am,
              levels = c(0,1),
              labels =c("automatic","manual"))

palette <- c(automatic = "#377EB8", manual = "#E41A1C")

ggplot(mapping = aes(fcyl, fill = fam)) +
  geom_bar() +
  labs(x = "Number of Cylinders", y = "Count") +
  # Set the fill color scale
  scale_fill_manual("Transmission is a legend title", values = palette)

1 Like