Change color conditional_smooths

I cannot change the colour of the conditional_smooths plot. I create the plot like so:

p1=conditional_smooths(model1)

but then this doesn’t change the color. I tried various ways (scale_color_grey()) but none worked.

plot(p1, plot=FALSE)[[1]] + scale_color_manual(values=“DC267F”)

What am I doing wrong?

  • Operating System: MacOS Catalina
  • brms Version: 2.15.0

I think you need scale_color_gradient here.

I tried that too and no results, tried scale_color_grey() too and nothing changes

1 Like

Can you post the full model code and a snippet of the data (or simulated data) that we can play with. It’s hard to recreate this on my end.

Know this is an old topic but posting for completeness. I, too, was unable to edit the color easily. For my money, it’s easier to extract the data and then make the plot:

# conditional smooths
smooths <- brms::conditional_smooths(mod)

# extract data for first smooth
data <- smooths[[1]]

# then make the plot ggplot2 

But if you don’t want to do that you can just add the color into the layer:

# extract the plot
plot <- plot(smooths, plot = FALSE)[[1]]

# change the lines to red
plot$layers[[1]]$aes_params$colour <- "red"

# plot it
plot

Or if you have a by = in your smoothing terms you can add the color to aes() of the call:

# extract the plot
plot <- plot(smooths, plot = FALSE)[[1]]

# add aes and color, fill, theme
plot +
    ggplot2::aes(color = Species, fill = Species) +
    ggplot2::scale_color_viridis_d() + 
    ggplot2::scale_fill_viridis_d() +
    ggplot2::theme_minimal()
1 Like