How to customize plots' colors from conditional_effects / brms models?

79 views Asked by At

So I've been looking around and trying to change the colors of my factor variable in a plot from a brms model. Basically, I have a X variable with 5 factors, and the measure from my experiment as Y (continuous). Within the 5 levels of my X variable, I have (1, 3, 5) as one condition, and (2, 4) as another condition.

When I plot the estimates of X variable through conditional_effects(), I get a nice plot, of 5 means and std bars, but all black.

I would like to color the plot with too colors, one for X=(1,3,5) and another for X=(2,4).

I have no idea which variable of the conditional_effects object to change for this purpose.

Thanks for any advice.

I tried this, which has no effect :

segmentEffect <- conditional_effects(model,effect = "segment")
myPlot <- plot(segmentEffect,plot=FALSE)[[1]] +
scale_fill_manual(values = c("1" = "cyan",
                             "2" = "pink",
                             "3" = "cyan",
                             "4" = "pink",
                             "5" = "cyan"))+
scale_colour_manual(values = c("1" = "cyan",
                               "2" = "pink",
                               "3" = "cyan",
                               "4" = "pink",
                               "5" = "cyan"))
myPlot
1

There are 1 answers

0
Saneesh C S On
segmentEffect.ce <- conditional_effects(model,effect = "segment") # save the conditional effects

segmentEffect.df <-
  as.data.frame(segmentEffect.ce$`segment`) # save the ce as a data frame and use it in ggplot

Try this it should work.