I am trying to set up a global ggplot2 color scheme in my global RMarkdown files and I had success with viridis
with the following code
options(
ggplot2.continuous.colour = "viridis",
ggplot2.continuous.fill = "viridis"
)
scale_colour_discrete = scale_colour_viridis_d
scale_fill_discrete = scale_fill_viridis_d
However, when I try to use a similar procedure with RColorBrewer, I was unable to do so with default color still showing up. What changes should I make for it to work?
options(
ggplot2.continuous.colour = "brewer",
ggplot2.continuous.fill = "brewer"
)
scale_colour_discrete = scale_colour_brewer(palette="Dark2")
scale_fill_discrete = scale_fill_brewer(palette="Dark2")
Discrete
If you wish to specify a default, discrete colour scale such as that produced by
scale_colour_brewer()
use theggplot2.discrete.colour
option. Similarly, use the optionggplot2.discrete.fill
for a discrete fill scale.Default Discrete Scales
Created on 2021-07-01 by the reprex package (v1.0.0)
Custom Discrete Scales
Created on 2021-07-01 by the reprex package (v1.0.0)
Continuous
If you wish to specify a default, continuous color scale, you will need to use
scale_colour_distiller()
instead ofscale_colour_brewer()
. Similarly, usescale_fill_distiller()
as opposed toscale_fill_brewer()
for a continuous fill scale. You will also use the optionsggplot2.continuous.colour
andggplot2.continuous.fill
respectively.Default Continuous Scales
Created on 2021-07-01 by the reprex package (v1.0.0)
Custom Continuous Scales
Created on 2021-07-01 by the reprex package (v1.0.0)