library(tidyverse)
library(RColorBrewer)
mtcars %>%
count(cyl) %>%
ungroup() %>%
ggplot(aes(cyl, n)) +
geom_line(size = 3) +
scale_color_brewer(palette = "Accent")
I'll often have a whole series of graphs with the color theme for each being scale_color_brewer(palette = "Accent")
. I want to maintain this theme throughout my .Rmd file, on all graphs. However, this scale_color_brewer()
only works if there's multiple lines on each plot.
For the case above (a single line), how do I apply scale_color_brewer(palette = "Accent")
, short of specifying the unique color as an argument in geom_line()
? I'm hoping there's a better solution than that manual process. Using different themes and having to look up all the different CMYK values gets tedious.
You could always set a color aesthetic and just turn off the legend
mtcars %>%
count(cyl) %>%
ungroup() %>%
ggplot(aes(cyl, n, color="A")) +
geom_line(size = 3) +
scale_color_brewer(palette = "Accent", guide="none")