fsolt/dotwhisker

Specifying multiple colors for dot_args

Closed this issue · 1 comments

I have 6 models (3 variations of two datasets) so I would like to specify a colour pallete for each of the models. adding to dot_args = (list (size = 2, colour = rep(c("#a67c00", "#bf9b30", "#ffbf00", "#d896ff", "#be29ec", "#660066")), 8 ))
or just colour = c("#a67c00", "#bf9b30", "#ffbf00", "#d896ff", "#be29ec", "#660066")
gives me the same error: Error: Aesthetics must be either length 1 or the same as the data (48): colour

@IsadoraBM I don't think that's the way you change color for ggplot2 objects. The dot_args passes arguments to the geom_point functions to modify the appearances systematically rather than manually. Here's a way you can set up the point color manually:

library(dotwhisker)
    
m1 <- lm(mpg ~ wt + cyl + disp + gear, data = mtcars)
m2 <- update(m1, . ~ . + hp) # add another predictor
m3 <- update(m2, . ~ . + am) # and another

x <- list(m1, m2, m3)
    
dwplot(x,
       dot_args = (list(size = 2))) +
    scale_color_manual(values = c("#a67c00", "#bf9b30", "#ffbf00"))

image

Again, free to reopen the issue if you still have problems dealing with the color, and a replicable example will be highly appreciated.